:root {
  --bg: #0e1014; --card: #171a21; --line: #2a2f3a; --text: #eceef2; --dim: #8b92a1;
  --ok: #2fa760; --danger: #d6455a; --accent: #3d7bd9;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.45 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
main { max-width: 960px; margin: 0 auto; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.narrow { max-width: 420px; margin: 40px auto; }
label { display: block; font-size: 13px; color: var(--dim); margin: 6px 0 4px; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }
input { background: #0b0d11; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; width: 100%; }
#pwForm { display: flex; gap: 8px; }
button { background: #2b3240; color: var(--text); border: 1px solid #3a4253; border-radius: 8px; padding: 10px 14px; font: inherit; cursor: pointer; white-space: nowrap; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.on { background: #4a2a30; border-color: var(--danger); }
.muted { color: var(--dim); font-size: 14px; }
.center { text-align: center; }
.error { color: #ff7a8a; font-size: 14px; min-height: 1em; }
.big { font-size: 20px; text-align: center; margin: 4px 0 16px; }
.banner { background: #5a4410; color: #ffe7a8; padding: 8px 16px; font-size: 13px; text-align: center; }

.share { display: flex; gap: 8px; margin-bottom: 8px; }
.share input { flex: 1; min-width: 0; font-size: 14px; }

.grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); position: relative; }
.tile { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.mirror video { transform: scaleX(-1); }
.tile .name { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.tile .state { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--dim); }
.tile .state:empty { display: none; }
.tile .tap { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); font-size: 15px; border: 0; border-radius: 0; }

/* Two people: the other person fills the screen, you sit in the corner. */
.grid.duo { display: block; }
.grid.duo .tile.remote { aspect-ratio: auto; height: min(72vh, 720px); }
.grid.duo .tile.local { position: absolute; right: 10px; bottom: 10px; width: 28%; max-width: 200px; aspect-ratio: 3 / 4; z-index: 2; border: 2px solid rgba(255,255,255,.25); }

.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal .card { margin: 0; width: 100%; }
.modal .row button { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b3240; padding: 10px 16px; border-radius: 10px; max-width: 90vw; z-index: 20; }
