:root {
  color: #f4f7ff;
  background: #74c9ee;
  font-family: Inter, "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 17% 17%, rgb(255 255 255 / 42%) 0 2%, transparent 18%),
    radial-gradient(ellipse at 78% 29%, rgb(255 255 255 / 28%) 0 2%, transparent 20%),
    linear-gradient(180deg, #168bc9 0%, #54b8e3 34%, #a9ddea 68%, #d6e3df 100%);
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  padding: 11px 16px;
  background: #253250;
  color: #ffffff;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.18s ease;
}

button:hover:not(:disabled) {
  background: #374972;
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.app-shell {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 28px 16px;
}

.call-panel {
  width: min(100%, 1040px);
}

.eyebrow {
  margin: 0 0 8px;
  color: #83b2ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  text-align: center;
}

.subtitle {
  color: #b8c2d9;
  line-height: 1.7;
}

.join-card,
.call-stage {
  margin-top: 26px;
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid rgb(255 255 255 / 48%);
  border-radius: 20px;
  background: rgb(232 248 255 / 67%);
  box-shadow: 0 24px 70px rgb(32 108 144 / 22%);
  color: #17324d;
  backdrop-filter: blur(16px);
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.room-entry {
  display: flex;
  gap: 10px;
}

input {
  min-width: 0;
  flex: 1;
  border: 1px solid rgb(77 142 181 / 55%);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
  background: rgb(255 255 255 / 72%);
  color: #17324d;
}

input:focus {
  border-color: #75a8ff;
  box-shadow: 0 0 0 3px rgb(117 168 255 / 18%);
}

.primary {
  background: #3979eb;
}

.primary:hover:not(:disabled) {
  background: #4d8dff;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  color: #31516d;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 100%;
  background: #d59a4e;
}

.status-dot.active {
  background: #4bd59a;
  box-shadow: 0 0 12px #4bd59a;
}

.bandwidth-stats {
  color: #31516d;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.text-button {
  margin-left: auto;
  padding: 6px 8px;
  background: transparent;
  color: #216eb0;
}

.videos {
  position: relative;
  min-height: clamp(300px, 52vw, 540px);
  overflow: hidden;
  border-radius: 15px;
  background: #050a14;
}

.video-tile {
  position: relative;
  overflow: hidden;
  position: absolute;
  inset: 0;
  border: 1px solid #344561;
  border-radius: 15px;
  background: #050a14;
  cursor: pointer;
  transition: all 0.22s ease;
  touch-action: none;
}

.video-tile:not(.is-main).is-dragging {
  transition: none;
  will-change: left, top;
}

.video-tile:not(.is-main) {
  z-index: 2;
  inset: auto 16px 16px auto;
  width: min(28%, 260px);
  aspect-ratio: 16 / 9;
  box-shadow: 0 8px 22px rgb(0 0 0 / 35%);
}

.screen-tile:not(.is-main) {
  right: calc(28% + 30px);
}

.video-tile.is-main {
  z-index: 1;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-tile video {
  transform: rotateY(180deg);
}

.video-label,
.video-placeholder {
  position: absolute;
  margin: 0;
}

.video-label {
  left: 10px;
  bottom: 10px;
  border-radius: 6px;
  padding: 4px 8px;
  background: rgb(0 0 0 / 55%);
  font-size: 13px;
}

.video-stats {
  position: absolute;
  right: 10px;
  bottom: 10px;
  margin: 0;
  border-radius: 5px;
  padding: 3px 6px;
  background: rgb(0 0 0 / 58%);
  color: #ffffff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.video-placeholder {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #9fb0cc;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}

#muteButton,
#cameraButton {
  background: #2e6fd2;
}

#flipCameraButton {
  background: #168b91;
}

#shareButton {
  background: #7657c7;
}

.control-button.is-off {
  background: #b86b2c;
}

.control-button:hover:not(:disabled) {
  filter: brightness(1.12);
}

.danger {
  background: #bb3d50;
}

.danger:hover:not(:disabled) {
  background: #d44d61;
}

#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 2;
  max-width: calc(100% - 32px);
  margin: 0;
  transform: translate(-50%, 20px);
  border-radius: 9px;
  padding: 10px 14px;
  background: #e6edf9;
  color: #162039;
  opacity: 0;
  transition: 0.2s ease;
}

#toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 620px) {
  .app-shell {
    padding: 18px 12px;
  }

  .room-entry,
  .room-entry {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .videos {
    min-height: min(118vw, 520px);
  }

  .video-tile:not(.is-main) {
    right: 10px;
    bottom: 10px;
    width: 34%;
    min-width: 112px;
  }

  .screen-tile:not(.is-main) {
    right: calc(34% + 20px);
  }

  .status-line {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .bandwidth-stats {
    width: 100%;
    order: 3;
  }

  .text-button {
    margin-left: 0;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .controls button {
    width: 100%;
    min-height: 46px;
    padding: 10px 8px;
    white-space: nowrap;
  }
}
