/* ---------- reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0d12;
  --bg-elevated: #14161d;
  --bg-elevated-2: #1b1e27;
  --accent: #0d7cfd;
  --accent-soft: #3fa4ff;
  --accent-pale: #cdd6ff;
  --danger: #ef4444;
  --text: #f5f6fa;
  --text-dim: #9aa0ae;
  --border: rgba(255, 255, 255, 0.1);
  --glass-fill: rgba(20, 22, 29, 0.72);
}

html, body { height: 100%; overscroll-behavior: none; }

body {
  font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* mobile-only frame: designed for portrait phones. Wider screens get a
   letterboxed phone-sized frame instead of stretching. */
.app {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  max-height: 940px;
  overflow: hidden;
  background: var(--bg);
}

@media (min-width: 461px) and (min-height: 700px) {
  .app {
    border-radius: 40px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), 0 0 0 10px rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}

.screen { position: absolute; inset: 0; }
.hidden { display: none !important; }

/* ---------- home screen ---------- */
.home-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow-y: auto;
}

.home-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo { width: 100%; max-width: 300px; height: auto; margin-bottom: 28px; }

.name-label {
  align-self: flex-start;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  margin-left: 2px;
}

.name-row {
  width: 100%;
  position: relative;
  margin-bottom: 22px;
}

.name-row input {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  padding: 14px 44px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  outline: none;
  transition: border-color 0.2s;
}
.name-row input:focus { border-color: var(--accent); }

.edit-name-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.edit-name-btn:active { background: rgba(255, 255, 255, 0.08); }

.btn {
  width: 100%;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 14px;
  padding: 15px 20px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { color: #fff; background: linear-gradient(135deg, var(--accent-soft), var(--accent)); }
.btn-primary:disabled { opacity: 0.55; pointer-events: none; }

.encryption-note {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ---------- meeting screen ---------- */
.meeting-screen {
  display: flex;
  flex-direction: column;
  background: #000;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
}

.tile {
  position: absolute;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mirroring is a local display preference only (like Zoom/Meet) — it never
   touches the actual frames sent over WebRTC, so it's free performance-wise
   and the remote tile is never mirrored regardless of our own setting. */
.tile.mirrored video { transform: scaleX(-1); }

.tile-big { inset: 0; }

.tile-small {
  bottom: 14px;
  right: 14px;
  width: 30%;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  z-index: 5;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}
.tile-small:active { transform: scale(0.95); }

.tile-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(10, 8, 20, 0.55);
  z-index: 1;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-big .tile-label { font-size: 14px; bottom: 16px; left: 16px; }
.tile-label:empty { display: none; }

/* peer connection state pill */
.conn-status {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: var(--glass-fill);
  border: 1px solid var(--border);
  white-space: nowrap;
}

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

.conn-status.state-connecting .conn-dot,
.conn-status.state-new .conn-dot {
  background: #f2b93d;
  box-shadow: 0 0 0 3px rgba(242, 185, 61, 0.25);
}

.conn-status.state-connected .conn-dot {
  background: #3ecf72;
  box-shadow: 0 0 0 3px rgba(62, 207, 114, 0.22);
}

.conn-status.state-disconnected .conn-dot {
  background: #f2b93d;
  box-shadow: 0 0 0 3px rgba(242, 185, 61, 0.25);
}

.conn-status.state-failed .conn-dot,
.conn-status.state-closed .conn-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.22);
}

.fallback-text {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}
.tile-small .fallback-text { font-size: 12px; }
.tile.video-off .fallback-text { display: flex; }
.tile.video-off video { visibility: hidden; }

/* bottom control bar */
.bottom-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 34px;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #12141a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn.active-off { background: var(--bg-elevated-2); color: var(--danger); }

.ctrl-end { background: var(--danger); color: #fff; }

.icon { width: 24px; height: 24px; }

/* toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 140px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 13px;
  z-index: 20;
  max-width: 85%;
  text-align: center;
  background: var(--glass-fill);
  border: 1px solid var(--border);
}
