body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #1a202c;
  margin: 0;
  padding: 0;
  color: #fff;
}

/* ----------- Header, Status, Footer ----------- */
h1 {
  margin-top: 0;
  text-align: center;
  font-size: 28px;
  color: #c7d2fe;
}

#status {
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 8px;
}

.connecting,
.bg-yellow-500 {
  background-color: #f1c40f !important;
  color: #fff !important;
}

.connected,
.bg-green-500 {
  background-color: #22c55e !important;
  color: #fff !important;
}

.disconnected,
.bg-red-600 {
  background-color: #e74c3c !important;
  color: #fff !important;
}

/* ----------- Inputs ----------- */
input,
textarea {
  background: #23272f;
  color: #fff;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 8px;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #6366f1;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

/* ----------- Device List ----------- */
ul#deviceList {
  padding-left: 18px;
}

/* ----------- Message Styles ----------- */
.message-block {
  max-height: 300px;
  overflow-y: auto;
  background: #18181b;
  padding: 10px;
  border: 1px solid #374151;
  border-radius: 8px;
}

.message {
  border-bottom: 1px solid #374151;
  padding: 8px;
  margin-bottom: 5px;
  background: #23272f;
  border-radius: 6px;
}

.message.urgent {
  border-left: 5px solid #dc2626;
  background-color: #fdecea;
  color: #a71b1b;
}

.message.normal {
  border-left: 5px solid #6366f1;
}

.message-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.sender-info {
  font-weight: bold;
  color: #818cf8;
}

.xr-id {
  margin-left: 10px;
  font-size: 12px;
  color: #7dd3fc;
}

.message-content {
  font-size: 15px;
  color: #f1f5f9;
}

.urgent-badge {
  background-color: #dc2626;
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 5px;
}

/* ----------- Recent Messages ----------- */
.recent-message {
  padding: 6px;
  margin-bottom: 5px;
  background: #23272f;
  border-radius: 6px;
  color: #f1f5f9;
}

.recent-message.urgent {
  background-color: #fdecea;
  border-left: 4px solid #dc2626;
  color: #a71b1b;
}

.recent-message-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 3px;
}

.system-message {
  background-color: #fef5cb;
  color: #7c4700;
  padding: 8px;
  border-left: 4px solid #f1c40f;
  margin: 5px 0;
  border-radius: 4px;
  font-style: italic;
}

/* ----------- Video ----------- */
#xrVideo,
#remoteVideo {
  display: block;
  margin: 0;
  max-height: 100%;
  width: 100%;
  object-fit: contain;
  background: #000;
  border: 2px solid #23272f;
  border-radius: 6px;
}

#videoOverlay {
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
  font-size: 2rem;
  font-weight: bold;
}

#muteBadge {
  z-index: 30;
  font-weight: bold;
  display: none;
}

.bg-overlay {
  background: rgba(0, 0, 0, 0.7);
}

/* ----------- Buttons ----------- */
button {
  transition: background-color 0.3s;
  font-weight: 500;
}

#sendButton,
#clearMessagesBtn,
#openEmulator {
  min-width: 100px;
  margin-left: 6px;
}

#sendButton:active,
#clearMessagesBtn:active,
#openEmulator:active {
  opacity: 0.8;
}

/* ----------- Responsive Styles ----------- */

/* Major layout stacking on tablet/mobile */
@media (max-width: 900px) {

  .flex,
  .flex-col,
  .flex-1 {
    flex-direction: column !important;
  }

  .w-2\/3,
  .w-1\/3 {
    width: 100% !important;
  }

  /* Panels and video get taller on mobile */
  .h-full,
  .h-auto {
    height: auto !important;
    min-height: 200px;
  }

  #xrVideo,
  #remoteVideo {
    min-height: 160px;
    height: 200px;
    max-height: 300px;
  }

  .max-h-32,
  .max-h-48,
  .max-h-24,
  .max-h-20 {
    max-height: 120px !important;
  }

  .space-y-6,
  .space-y-4 {
    gap: 1rem !important;
  }
}

/* Further optimize for very small screens */
@media (max-width: 600px) {
  h1 {
    font-size: 20px;
  }

  #status {
    font-size: 12px;
    padding: 2px 6px;
  }

  .container {
    padding: 8px;
  }

  .px-3,
  .px-4,
  .px-6 {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .py-3,
  .py-4,
  .py-6 {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .rounded,
  .rounded-full,
  .rounded-lg {
    border-radius: 4px !important;
  }

  #xrVideo,
  #remoteVideo {
    height: 140px !important;
  }

  textarea {
    height: 60px !important;
  }
}

@media (max-width: 400px) {

  .recent-message-header,
  .message-header {
    font-size: 11px !important;
  }

  .sender-info,
  .xr-id {
    font-size: 10px !important;
  }

  .message-content,
  .recent-message-content {
    font-size: 12px !important;
  }
}

/* ----------- Mirror mode for XR video ----------- */
#xrVideo.mirror {
  transform: scaleX(-1);
}

.sigbars {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  /* puts bars right after the battery chip */
  opacity: 0.95;
}