:root {
  --bg: #0f1115;
  --bg-elevated: #181b22;
  --bg-tile: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --accent: #5b8def;
  --accent-hover: #4a7ce0;
  --danger: #ea4335;
  --danger-hover: #d63a2e;
  --green: #34a853;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  font-family: "Google Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: var(--text);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select {
  font-family: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
}

/* ---------- Landing ---------- */

.landing {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 600;
  padding: 8px 0 48px;
}

.brand .dot {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  display: grid;
  place-items: center;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 560px;
}

.hero h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 16px;
  font-weight: 600;
}

.hero p {
  font-size: 18px;
  color: var(--text-dim);
  margin: 0 0 36px;
}

.actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.join-group {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 280px;
}

.join-group input {
  flex: 1;
}

.hint {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Pre-join ---------- */

.prejoin {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
}

@media (max-width: 860px) {
  .prejoin {
    grid-template-columns: 1fr;
  }
}

.preview-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 16px;
  text-align: center;
  padding: 20px;
}

.preview-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
}

.mic-meter {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 22px;
}

.mic-meter span {
  width: 4px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: background 0.1s;
}

.setup h2 {
  font-size: 26px;
  margin: 0 0 8px;
}

.setup .room-label {
  color: var(--text-dim);
  margin: 0 0 28px;
  font-size: 15px;
}

.setup .room-label b {
  color: var(--text);
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
}

.setup .btn-primary {
  width: 100%;
  margin-top: 8px;
}

/* round icon buttons used in preview + control bar */
.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-tile);
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.05s;
}

.icon-btn:hover:not(:disabled) {
  background: #2b313c;
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.icon-btn.off {
  background: var(--danger);
}

.icon-btn.off:hover:not(:disabled) {
  background: var(--danger-hover);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--text);
}

.icon-btn .icon-on {
  display: block;
}
.icon-btn .icon-off {
  display: none;
}
.icon-btn.off .icon-on {
  display: none;
}
.icon-btn.off .icon-off {
  display: block;
}

/* ---------- Room ---------- */

.room {
  display: none;
  flex-direction: column;
  height: 100%;
}

.room.active {
  display: flex;
}

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.grid {
  flex: 1;
  display: grid;
  gap: 10px;
  padding: 16px;
  min-height: 0;
  align-content: center;
  justify-content: center;
  grid-auto-rows: 1fr;
}

/* spotlight layout: one big tile + filmstrip */
.stage.spotlight .grid {
  display: none;
}

.spotlight-main {
  display: none;
  flex: 1;
  padding: 16px;
  min-height: 0;
}

.stage.spotlight .spotlight-main {
  display: block;
}

.spotlight-main .tile {
  width: 100%;
  height: 100%;
}

.filmstrip {
  display: none;
}

.stage.spotlight .filmstrip {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 220px;
  padding: 16px 16px 16px 0;
  overflow-y: auto;
}

.stage.spotlight .filmstrip .tile {
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
}

.tile {
  position: relative;
  background: var(--bg-tile);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  border: 2px solid transparent;
  transition: border-color 0.12s;
}

.tile.speaking {
  border-color: var(--accent);
}

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

.tile.screenshare video {
  object-fit: contain;
  background: #000;
}

.tile.mirror video {
  transform: scaleX(-1);
}

.tile .avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.tile.has-video .avatar {
  display: none;
}

.tile .avatar .circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 600;
  text-transform: uppercase;
}

.tile .label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 20px);
}

.tile .label .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .muted-mic {
  display: none;
}

.tile.mic-off .muted-mic {
  display: inline-flex;
}

.tile .muted-mic svg {
  width: 15px;
  height: 15px;
  fill: var(--danger);
}

/* ---------- Control bar ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  position: relative;
}

.controls .meeting-info {
  position: absolute;
  left: 20px;
  color: var(--text-dim);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls .right-tools {
  position: absolute;
  right: 20px;
  display: flex;
  gap: 12px;
}

.icon-btn.leave {
  background: var(--danger);
  width: 60px;
}

.icon-btn.leave:hover {
  background: var(--danger-hover);
}

.icon-btn.active-tool {
  background: var(--accent);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  place-items: center;
  padding: 0 4px;
}

.badge.show {
  display: grid;
}

.icon-btn {
  position: relative;
}

/* ---------- Side panel (chat / people) ---------- */

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.panel {
  width: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.18s ease;
}

.panel.open {
  width: 340px;
}

@media (max-width: 600px) {
  .panel.open {
    width: 100%;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
  }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.panel-header .close {
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
}

/* chat */
.chat-msg {
  margin-bottom: 14px;
}

.chat-msg .meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.chat-msg .meta .who {
  color: var(--accent);
  font-weight: 600;
}

.chat-msg .text {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-empty {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  margin-top: 30px;
}

.chat-compose {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.chat-compose input {
  flex: 1;
}

.chat-compose button {
  background: var(--accent);
  border-radius: 8px;
  padding: 0 16px;
}

/* people list */
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
}

.person .circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.person .pname {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person .status {
  display: flex;
  gap: 8px;
}

.person .status svg {
  width: 18px;
  height: 18px;
  fill: var(--text-dim);
}

.person .status .off svg {
  fill: var(--danger);
}

/* ---------- Banners / toasts ---------- */

.banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 30;
  display: none;
  align-items: center;
  gap: 10px;
}

.banner.show {
  display: flex;
}

.banner button {
  background: var(--accent);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

#audio-sink {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.center-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.center-screen h2 {
  font-size: 26px;
  margin: 0 0 10px;
}

.center-screen p {
  color: var(--text-dim);
  margin: 0 0 24px;
  max-width: 420px;
}

/* ---------- Tile actions (fullscreen) ---------- */

.tile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s;
}

.tile:hover .tile-actions {
  opacity: 1;
}

/* touch devices have no hover — keep the controls visible */
@media (hover: none) {
  .tile-actions {
    opacity: 0.9;
  }
}

.tile-actions button {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
}

.tile-actions button:hover {
  background: rgba(0, 0, 0, 0.78);
}

.tile-actions button svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.tile:fullscreen,
.tile:-webkit-full-screen {
  border: none;
  border-radius: 0;
}

.tile:fullscreen video,
.tile:-webkit-full-screen video {
  object-fit: contain;
  background: #000;
}

.controls .meeting-info {
  cursor: pointer;
}

/* ---------- Mobile / small screens ---------- */

@media (max-width: 760px) {
  .controls {
    gap: 8px;
    padding: 10px 8px;
    flex-wrap: wrap;
  }
  .controls .meeting-info {
    display: none;
  }
  .icon-btn {
    width: 44px;
    height: 44px;
  }
  .icon-btn svg {
    width: 22px;
    height: 22px;
  }
  .icon-btn.leave {
    width: 54px;
  }
  .grid {
    padding: 8px;
    gap: 8px;
  }

  /* Spotlight stacks vertically: big view on top, filmstrip a row below.
     This is what makes a shared screen actually visible on a phone. */
  .stage.spotlight {
    flex-direction: column;
  }
  .stage.spotlight .spotlight-main {
    padding: 8px;
    min-height: 0;
  }
  .stage.spotlight .filmstrip {
    flex-direction: row;
    width: 100%;
    height: 84px;
    padding: 0 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .stage.spotlight .filmstrip .tile {
    height: 100%;
    width: auto;
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
  }
}

.hidden {
  display: none !important;
}
