:root {
  color-scheme: dark;
  --bg: #14161a;
  --panel: #1e2127;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --accent: #4c8bf5;
}

* {
  box-sizing: border-box;
}

/* A display-setting selector (e.g. .grid, .lobby) otherwise overrides the
   user-agent rule that makes [hidden] elements display: none. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family:
    system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.landing {
  max-width: 32rem;
  margin: 12vh auto;
  padding: 0 1.5rem;
  text-align: center;
}

.landing h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.landing p {
  color: var(--muted);
  margin: 0.3rem 0;
}

.landing form {
  margin-top: 2rem;
}

.brand {
  font-weight: 600;
  text-align: center;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
}

/* ---- Lobby (pre-join preview) ------------------------------------------- */

.lobby {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(28rem, 100%);
  margin: 6vh auto;
  padding: 0 1.25rem;
}

.preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  object-fit: cover;
  transform: scaleX(-1); /* mirror the self-view, like a real mirror */
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.field select {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid #000;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: 1rem;
}

.meter {
  height: 0.6rem;
  border-radius: 999px;
  background: #000;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 60ms linear;
}

.lobby #join {
  align-self: stretch;
}

/* In-call: nothing but feeds, filling the whole viewport. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.4rem;
  padding: 0.4rem;
  min-height: 100dvh;
}

.tile {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

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

.tile.dimmed video {
  visibility: hidden;
}

.tile.dimmed::after {
  content: "Camera off";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.tile-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Controls overlaid on your own tile, revealed on hover (or keyboard focus). */
.tile-controls {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.tile:hover .tile-controls,
.tile:focus-within .tile-controls {
  opacity: 1;
  pointer-events: auto;
}

.tile-control {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  background: rgba(20, 22, 26, 0.85);
}

.tile-control.control-off {
  background: #c0392b; /* red while muted / camera off */
}

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--panel);
  border: 1px solid #000;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.screen-body {
  margin: 0;
  background: #000;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-body video {
  max-width: 100%;
  max-height: 100%;
}

.screen-status {
  position: fixed;
  color: var(--muted);
}
