/* Pele Meet - Zoom-like dark UI */
:root {
  --bg: #16161a;
  --bg-2: #1f1f26;
  --panel: #26262e;
  --panel-2: #2f2f38;
  --line: #37373f;
  --text: #f2f2f5;
  --muted: #9a9aa5;
  --accent: #2d8cff;      /* Zoom blue */
  --accent-hover: #1f7ae0;
  --danger: #e0483d;
  --danger-hover: #c93a30;
  --good: #33b579;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.screen { height: 100%; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- LOBBY ---------------- */
#lobby {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #23232c 0%, var(--bg) 60%);
}
.lobby-card {
  width: 100%; max-width: 420px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(45,140,255,0.18);
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: -0.3px; }
.tagline { color: var(--muted); font-size: 13.5px; margin: 8px 0 18px; line-height: 1.5; }

.preview-wrap {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #0c0c0f; border-radius: var(--radius); overflow: hidden;
  margin-bottom: 18px; border: 1px solid var(--line);
}
#previewVideo { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; background: #0c0c0f;
}
.preview-controls {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; gap: 12px; justify-content: center;
}
.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.14); color: #fff;
  display: grid; place-items: center; backdrop-filter: blur(6px);
  transition: background .15s;
}
.round-btn:hover { background: rgba(255,255,255,0.24); }
.round-btn.off { background: var(--danger); }
.round-btn::before { content: ""; width: 20px; height: 20px; background: currentColor;
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
#preMic::before { -webkit-mask-image: var(--ic-mic); mask-image: var(--ic-mic); }
#preMic.off::before { -webkit-mask-image: var(--ic-mic-off); mask-image: var(--ic-mic-off); }
#preCam::before { -webkit-mask-image: var(--ic-cam); mask-image: var(--ic-cam); }
#preCam.off::before { -webkit-mask-image: var(--ic-cam-off); mask-image: var(--ic-cam-off); }

/* Device pickers */
.devices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.dev {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.dev-ico {
  width: 18px; height: 18px; flex: none; background: var(--muted);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.dev-ico[data-ico="cam"] { -webkit-mask-image: var(--ic-cam); mask-image: var(--ic-cam); }
.dev-ico[data-ico="mic"] { -webkit-mask-image: var(--ic-mic); mask-image: var(--ic-mic); }
.dev-ico[data-ico="spk"] { -webkit-mask-image: var(--ic-spk); mask-image: var(--ic-spk); }
.dev select {
  flex: 1; min-width: 0; background: transparent; border: none; color: var(--text);
  padding: 11px 0; font-size: 13.5px; outline: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  text-overflow: ellipsis;
}
.dev select option { background: var(--panel-2); color: var(--text); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.ghost-btn {
  padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px; white-space: nowrap;
}
.ghost-btn:hover { background: var(--panel-2); }

.primary-btn {
  width: 100%; margin-top: 6px; padding: 13px; font-size: 15.5px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; border-radius: 11px;
  transition: background .15s, transform .05s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: scale(0.99); }
.primary-btn:disabled { opacity: .55; cursor: default; }
.invite-hint { color: var(--muted); font-size: 11.5px; margin: 7px 2px 0; line-height: 1.4; }
#inviteLink { font-size: 12.5px; color: var(--muted); cursor: text; }
.hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 12px 0 0; min-height: 16px; }

/* tile connection status */
.tile .status {
  position: absolute; top: 10px; left: 10px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(4px);
  display: flex; align-items: center; gap: 6px;
}
.tile .status .dot { width: 7px; height: 7px; border-radius: 50%; background: #e0a03d; }
.tile .status.connected { display: none; }
.lobby-foot { margin-top: 20px; color: #55555f; font-size: 12px; }

/* ---------------- CALL ---------------- */
#call { display: flex; flex-direction: column; height: 100%; background: #0c0c0f; }
.call-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.call-title { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px rgba(51,181,121,0.2); }
.call-top-right { display: flex; align-items: center; gap: 12px; }
.clock { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pill-btn {
  padding: 7px 13px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 12.5px;
}
.pill-btn:hover { background: var(--panel-2); }
.pill-btn.done { background: var(--good); border-color: var(--good); color: #062; }

/* Stage / grid */
.stage {
  flex: 1; display: grid; gap: 10px; padding: 12px;
  grid-template-columns: 1fr; align-content: center; justify-content: center;
  overflow: hidden; transition: margin-right .2s;
}
.stage.with-chat { margin-right: 320px; }
.stage[data-count="2"] { grid-template-columns: 1fr 1fr; }
.stage[data-count="3"], .stage[data-count="4"] { grid-template-columns: 1fr 1fr; }
.stage[data-count="5"], .stage[data-count="6"] { grid-template-columns: repeat(3, 1fr); }

.tile {
  position: relative; background: #17171c; border-radius: var(--radius);
  overflow: hidden; min-height: 0; aspect-ratio: 16/10; border: 2px solid transparent;
  transition: border-color .15s;
}
.tile.speaking { border-color: var(--good); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #17171c; }
.tile video.mirror { transform: scaleX(-1); }
.tile .avatar {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #17171c;
}
.tile .avatar span {
  width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 34px; font-weight: 600;
}
.tile .name {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 12.5px;
  padding: 4px 9px; border-radius: 7px; display: flex; align-items: center; gap: 6px;
  backdrop-filter: blur(4px);
}
.tile .mini-muted { width: 13px; height: 13px; background: currentColor;
  -webkit-mask: var(--ic-mic-off) center/contain no-repeat; mask: var(--ic-mic-off) center/contain no-repeat;
  color: var(--danger); }

/* Controls */
.controls {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; background: var(--bg); border-top: 1px solid var(--line);
}
.ctrl {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 68px; padding: 8px 10px; border-radius: 12px;
  background: transparent; border: none; color: var(--text);
  transition: background .15s;
}
.ctrl:hover { background: var(--panel); }
.ctrl small { font-size: 11px; color: var(--muted); }
.ctrl-ico { width: 24px; height: 24px; background: currentColor;
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center; }
.ctrl-ico[data-ico="mic"] { -webkit-mask-image: var(--ic-mic); mask-image: var(--ic-mic); }
.ctrl-ico[data-ico="cam"] { -webkit-mask-image: var(--ic-cam); mask-image: var(--ic-cam); }
.ctrl-ico[data-ico="share"] { -webkit-mask-image: var(--ic-share); mask-image: var(--ic-share); }
.ctrl-ico[data-ico="chat"] { -webkit-mask-image: var(--ic-chat); mask-image: var(--ic-chat); }
.ctrl-ico[data-ico="leave"] { -webkit-mask-image: var(--ic-leave); mask-image: var(--ic-leave); }
.ctrl[data-on="false"] .ctrl-ico[data-ico="mic"] { -webkit-mask-image: var(--ic-mic-off); mask-image: var(--ic-mic-off); color: var(--danger); }
.ctrl[data-on="false"] .ctrl-ico[data-ico="cam"] { -webkit-mask-image: var(--ic-cam-off); mask-image: var(--ic-cam-off); color: var(--danger); }
.ctrl.active { background: rgba(45,140,255,0.18); }
.ctrl.active .ctrl-ico { color: var(--accent); }
.ctrl.leave .ctrl-ico { color: var(--danger); }
.ctrl.leave:hover { background: rgba(224,72,61,0.15); }
.badge {
  position: absolute; top: 4px; right: 10px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; display: grid; place-items: center;
}

/* Chat */
.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 320px;
  background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 20;
}
.chat-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.icon-x { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; }
.icon-x:hover { color: var(--text); }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 8px 11px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.msg .who { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg.them { background: var(--panel); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.me .who { color: rgba(255,255,255,0.75); }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.chat-input { display: flex; gap: 8px; padding: 12px 16px 4px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 20px; outline: none; font-size: 13.5px; }
.chat-input input:focus { border-color: var(--accent); }
.chat-send { padding: 0 16px; border-radius: 20px; border: none; background: var(--accent); color: #fff; font-size: 13px; }
.chat-note { color: #55555f; font-size: 11px; text-align: center; padding: 4px 16px 12px; margin: 0; }

/* ---------------- STUDIO (teacher panel) ---------------- */
.studio-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px;
  background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 25;
}
.studio-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.studio-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; }
.studio-field { display: block; margin-bottom: 14px; }
.studio-field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.studio-field input { width: 100%; padding: 10px 12px; font-size: 14px; background: var(--panel);
  border: 1px solid var(--line); color: var(--text); border-radius: 9px; outline: none; }
.studio-field input:focus { border-color: var(--accent); }

.rec-status { font-size: 12.5px; color: var(--muted); padding: 8px 10px; margin-bottom: 12px;
  background: var(--panel); border-radius: 9px; display: flex; align-items: center; gap: 8px; }
.rec-status.live { color: var(--text); }
.rec-status.live::before { content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 3px rgba(224,72,61,0.25); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.take-save { width: 100%; padding: 13px; font-size: 15px; font-weight: 600; color: #fff;
  background: var(--danger); border: none; border-radius: 11px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center; gap: 9px; transition: background .15s; }
.take-save:hover:not(:disabled) { background: var(--danger-hover); }
.take-save:disabled { opacity: .45; cursor: default; }
.take-save small { font-weight: 400; opacity: .85; }
.take-save-dot { width: 11px; height: 11px; border-radius: 50%; background: #fff; }

.takes-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 10px; display: flex; gap: 6px; }
.takes-head span { background: var(--panel-2); border-radius: 10px; padding: 0 7px; color: var(--text); }
.takes-list { display: flex; flex-direction: column; gap: 10px; }
.take-item { background: var(--panel); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.take-item.active { border-color: var(--accent); }
.take-thumb { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; cursor: pointer; }
.take-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.take-thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.7);
  color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 5px; }
.take-thumb .play-badge { position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 28px; opacity: .85; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.take-meta { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.take-meta input { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text);
  font-size: 13px; outline: none; padding: 2px 0; border-bottom: 1px solid transparent; }
.take-meta input:focus { border-bottom-color: var(--line); }
.take-mini { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 4px; }
.take-mini:hover { color: var(--text); }

.review-box { border-top: 1px solid var(--line); padding: 12px 16px; background: var(--bg); }
.review-box video { width: 100%; border-radius: 10px; background: #000; max-height: 200px; }
.review-title { font-size: 13px; margin: 8px 0; color: var(--text); font-weight: 600; }
.review-actions { display: flex; gap: 8px; }
.review-btn { flex: 1; padding: 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; }
.review-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.review-btn.primary:hover { background: var(--accent-hover); }
.review-btn.live-on { background: var(--good); border-color: var(--good); color: #052; }
.showing-note { font-size: 11.5px; color: var(--good); margin: 8px 0 0; line-height: 1.4; }

.ctrl-ico[data-ico="studio"] { -webkit-mask-image: var(--ic-studio); mask-image: var(--ic-studio); }
.ctrl.active .ctrl-ico[data-ico="studio"] { color: var(--accent); }

@media (max-width: 640px) {
  .stage.with-chat { margin-right: 0; }
  .chat-panel, .studio-panel { width: 100%; }
  .ctrl { min-width: 52px; }
  .ctrl small { display: none; }
}

/* ---------- inline icon set (data URIs, no external requests) ---------- */
:root {
  --ic-mic: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"/><path d="M19 12a7 7 0 0 1-14 0H3a9 9 0 0 0 8 8.94V23h2v-2.06A9 9 0 0 0 21 12z"/></svg>');
  --ic-mic-off: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M15 12V6a3 3 0 0 0-5.94-.6L15 11.3zM3.3 2 2 3.3l6 6V12a3 3 0 0 0 4.7 2.46l1.5 1.5A7 7 0 0 1 5 12H3a9 9 0 0 0 8 8.94V23h2v-2.06a8.9 8.9 0 0 0 3.2-1.06l3.5 3.5 1.3-1.3z"/></svg>');
  --ic-cam: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11z"/></svg>');
  --ic-cam-off: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M3.3 2 2 3.3 4.7 6H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 .7-.3l3.99 4 1.3-1.3zM17 7v3.5l4-4v11l-.06.06L7.2 6H16a1 1 0 0 1 1 1z"/></svg>');
  --ic-share: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M20 4H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h5v2H7v2h10v-2h-2v-2h5a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 12H4V6h16zM12 7l-4 4h2.5v3h3v-3H16z"/></svg>');
  --ic-chat: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M4 3h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2z"/></svg>');
  --ic-spk: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4zM14 3.2v2.1a7 7 0 0 1 0 13.4v2.1a9 9 0 0 0 0-17.6z"/></svg>');
  --ic-studio: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M4 4h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-6l3 4H7l3-4H4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm6 3v6l5-3z"/></svg>');
  --ic-leave: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M21 15.46l-5.27-.61-2.52 2.52a15.05 15.05 0 0 1-6.59-6.59l2.53-2.53L8.54 3 3.03 3A18 18 0 0 0 21 20.97z" transform="rotate(135 12 12)"/></svg>');
}
