:root {
  --ink: #15202b;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --blue: #315df4;
  --teal: #00a68a;
  --coral: #e95744;
  --amber: #f2aa2e;
  --violet: #7357d9;
  --shadow: 0 18px 55px rgba(21, 32, 43, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(49, 93, 244, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(0, 166, 138, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-weight: 800;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

.brand-lockup p,
.match-profile span,
.match-stats,
.section-title,
.remote-overlay,
.messages {
  color: var(--muted);
}

.queue-card,
.interests,
.safety-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(21, 32, 43, 0.06);
}

.status-row,
.match-stats,
.toggle-row,
.top-bar,
.match-profile,
.control-dock,
.chat-strip {
  display: flex;
  align-items: center;
}

.status-row {
  gap: 10px;
  font-weight: 700;
}

.live-dot {
  width: 10px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(0, 166, 138, 0.13);
}

.match-meter {
  height: 8px;
  margin: 18px 0 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.match-meter span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--amber));
  transition: width 320ms ease;
}

.match-stats {
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.section-title {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chip {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}

.chip.is-active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.toggle-row {
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  font-weight: 650;
}

input[type="checkbox"] {
  width: 44px;
  height: 24px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: #cfd6e1;
  position: relative;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  transition: transform 180ms ease;
}

input[type="checkbox"]:checked {
  background: var(--teal);
}

input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto minmax(40px, auto) auto;
  gap: 14px;
  min-width: 0;
  padding: 22px;
}

.top-bar {
  justify-content: space-between;
  gap: 16px;
}

.match-profile {
  min-width: 0;
  gap: 12px;
}

.match-profile div {
  min-width: 0;
}

.match-profile strong,
.match-profile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #fff;
  background: var(--violet);
  font-weight: 800;
}

.rating-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(0, 166, 138, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  color: #006b5a;
  background: rgba(0, 166, 138, 0.1);
  font-weight: 800;
}

.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 31%);
  gap: 14px;
  min-height: 0;
}

.video-tile {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid rgba(21, 32, 43, 0.1);
  border-radius: 8px;
  background: #111827;
  box-shadow: var(--shadow);
}

.remote-tile {
  min-height: 430px;
}

canvas,
video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#remoteVideo {
  display: none;
}

#remoteVideo.is-live {
  display: block;
}

#remoteVideo.is-live + #remoteCanvas {
  display: none;
}

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

.camera-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: #fff;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(21, 32, 43, 0.84), rgba(49, 93, 244, 0.72)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 12px);
}

.camera-empty.is-hidden {
  display: none;
}

.camera-icon {
  font-size: 42px;
  line-height: 1;
}

.video-label,
.remote-overlay {
  position: absolute;
  left: 14px;
  bottom: 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(16px);
}

.video-label {
  padding: 8px 10px;
  font-weight: 800;
}

.remote-overlay {
  right: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.remote-overlay span,
.remote-overlay strong {
  display: block;
}

.remote-overlay span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.remote-overlay strong {
  color: #fff;
}

.scan-line {
  width: 4px;
  height: 42px;
  border-radius: 999px;
  background: var(--teal);
}

.chat-strip {
  gap: 10px;
}

.chat-strip input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.chat-strip input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(49, 93, 244, 0.12);
}

.messages {
  display: flex;
  gap: 8px;
  min-height: 40px;
  overflow-x: auto;
  font-size: 14px;
}

.message-pill {
  flex: 0 0 auto;
  max-width: min(520px, 86vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
}

.control-dock {
  justify-content: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 40px rgba(21, 32, 43, 0.1);
}

.icon-button,
.primary-action {
  display: grid;
  place-items: center;
  height: 48px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  width: 48px;
  color: var(--ink);
  background: #edf1f6;
}

.icon-button:hover,
.primary-action:hover,
.chip:hover {
  transform: translateY(-1px);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.is-active {
  color: #fff;
  background: var(--blue);
}

.icon-button.danger {
  color: #fff;
  background: var(--coral);
}

.primary-action {
  min-width: 148px;
  padding: 0 24px;
  color: #fff;
  background: var(--teal);
}

.primary-action.is-searching {
  background: var(--amber);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-lockup {
    grid-column: 1 / -1;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .local-tile {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .side-panel,
  .stage {
    padding: 14px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .top-bar {
    align-items: flex-start;
  }

  .rating-badge {
    padding: 8px 10px;
  }

  .remote-tile {
    min-height: 360px;
  }

  .control-dock {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .icon-button,
  .primary-action {
    width: 100%;
    min-width: 0;
  }

  .primary-action {
    padding: 0 8px;
  }
}
