:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  background: #0b0b0c; color: #f5f5f7;
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; height: 100dvh; padding: 16px; }
.left { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.card { background: #1c1c1e; border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.note { color: #a1a1a6; font-size: 16px; }
.note:empty { display: none; }
.note.warn { color: #ffd60a; }

button, input { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  background: #2c2c2e; cursor: pointer; white-space: nowrap;
}
button:hover { background: #3a3a3c; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #0a64d8; }
button.danger { background: #b3261e; }
input:not([type="range"]) {
  min-height: 44px; padding: 0 14px; border: 1px solid #3a3a3c; border-radius: 12px; background: #111113;
}
:focus-visible { outline: 3px solid #64a8ff; outline-offset: 2px; }

.stage {
  position: relative; flex: 1; min-height: 320px; overflow: hidden;
  display: flex; flex-direction: column;
  background: #000; border-radius: 20px;
}
.view { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#me {
  position: absolute; left: 12px; top: 12px; max-width: calc(70% - 36px);
  padding: 6px 12px; border-radius: 12px; background: rgb(0 0 0 / .72); font-size: 16px;
}
#remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#remote.blank { opacity: 0; }
#placeholder { position: relative; color: #a1a1a6; text-align: center; padding: 16px; }
#self {
  position: absolute; right: 12px; top: 12px; width: min(28%, 220px);
  border-radius: 12px; transform: scaleX(-1); background: #111;
}
#unblock { position: absolute; z-index: 2; }
.lobby {
  position: absolute; inset: 0; z-index: 3; margin: auto; width: min(100% - 32px, 360px); height: fit-content;
  display: flex; flex-direction: column; gap: 12px; padding: 20px; background: #1c1c1e; border-radius: 20px;
}
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / .75));
}
.volume { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; background: #2c2c2e; border-radius: 999px; }
.volume input { width: 110px; }
.to-chat { display: none; } /* chat is already beside the video on wide screens */
.stage.full .to-chat { display: block; }
.stage:fullscreen .to-chat { display: block; }

/* Nothing to control until you are in the call. */
.lobby:not([hidden]) ~ .controls { display: none; }

/* Used where the browser has no element full screen (iPhone). */
.stage.full { position: fixed; inset: 0; z-index: 10; border-radius: 0; }
.stage:fullscreen { border-radius: 0; }

.chat { display: flex; flex-direction: column; gap: 12px; min-height: 0; background: #1c1c1e; border-radius: 20px; padding: 12px; }
#messages { flex: 1; overflow-y: auto; list-style: none; display: flex; flex-direction: column; gap: 8px; }
#messages li { max-width: 85%; padding: 8px 14px; border-radius: 18px; background: #2c2c2e; white-space: pre-wrap; overflow-wrap: anywhere; }
#messages li.mine { align-self: flex-end; background: #0a64d8; }
#messages li.theirs { align-self: flex-start; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); height: auto; padding: 12px; }
  /* Controls sit under the picture instead of covering it. */
  .stage { flex: none; min-height: 0; }
  .view { min-height: max(42dvh, 280px); }
  .controls { position: static; display: grid; grid-template-columns: 1fr 1fr; background: none; }
  .controls button { padding: 0 8px; }
  .to-chat { display: block; grid-column: 1 / -1; }
  .volume { grid-column: 1 / -1; justify-content: center; order: 1; }
  .chat { height: 360px; }
  #self { width: 30%; }
}
