* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Outfit", "Poppins", system-ui, sans-serif;
  background: #05060d;
  color: #e8e8e8;
  min-height: 100vh;
}

.chat-header {
  max-width: 1100px;
  margin: 0 auto;
  background: transparent;
  padding: 1rem 1.15rem 0.5rem;
  border-bottom: none;
  position: relative;
  top: auto;
  z-index: 5;
}

.group-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.back-link {
  display: inline-block;
  color: #7dd3fc;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.back-link:hover {
  text-decoration: underline;
}

.chat-header h1 {
  font-size: 1.55rem;
  color: #fff;
  font-weight: 700;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.main-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.15rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* Chat at top on phones */
#chatColumn {
  order: -1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

@media (min-width: 800px) {
  .main-layout {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    align-items: start;
  }

  #chatColumn {
    order: 0;
    grid-column: 2;
    grid-row: 1 / span 3;
    position: sticky;
    top: calc(var(--app-header, 72px) + 12px);
    align-self: start;
  }

  #meetSection {
    grid-column: 1;
    grid-row: 1;
  }

  #membersSection {
    grid-column: 1;
    grid-row: 2;
  }

  #ownerSection {
    grid-column: 1;
    grid-row: 3;
  }
}

.meet-section h2,
.chat-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #00bfff;
}

.meet-card {
  background: rgba(16, 18, 34, 0.72);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid rgba(140, 160, 255, 0.18);
}

.meet-city {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5rem;
}

.meet-place {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.meet-address {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.75rem;
}

.map-link {
  display: inline-block;
  color: #00bfff;
  text-decoration: none;
  font-size: 0.9rem;
}

.map-link:hover {
  text-decoration: underline;
}

/* —— Interactive chat panel —— */
.chat-section {
  display: flex !important;
  flex-direction: column;
  min-height: 460px;
  background: linear-gradient(180deg, #12151c 0%, #0d1016 100%);
  border: 1px solid rgba(0, 191, 255, 0.28);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.chat-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-section-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-expand-btn {
  margin: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(0, 191, 255, 0.35);
  background: rgba(0, 191, 255, 0.1);
  color: #7dd3fc;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-expand-btn:hover {
  background: rgba(0, 191, 255, 0.22);
}

.chat-close-btn {
  font-size: 1.4rem;
  font-weight: 600;
}

.chat-section.is-fullscreen {
  position: fixed !important;
  inset: 0;
  z-index: 3000;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  min-height: 0;
  border-radius: 0;
  margin: 0;
  padding: max(0.85rem, env(safe-area-inset-top, 0px)) 1rem
    max(0.85rem, env(safe-area-inset-bottom, 0px));
  display: flex !important;
  flex-direction: column;
  background: #07090d;
  box-shadow: none;
  border: none;
  overflow: hidden;
}

.chat-section.is-fullscreen .chat-section-head,
.chat-section.is-fullscreen .chat-quick,
.chat-section.is-fullscreen .chat-form {
  flex-shrink: 0;
}

.chat-section.is-fullscreen .chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  height: auto;
  margin-bottom: 0.55rem;
  cursor: default;
}

.chat-section.is-fullscreen .chat-expand-btn#chatExpandBtn {
  display: none;
}

.chat-section.is-fullscreen .chat-close-btn {
  display: inline-flex !important;
}

body.chat-fullscreen-open {
  overflow: hidden !important;
  padding: 0 !important;
}

body.chat-fullscreen-open .site-header,
body.chat-fullscreen-open .app-tabbar,
body.chat-fullscreen-open .chat-header,
body.chat-fullscreen-open #chatTopBar,
body.chat-fullscreen-open #meetSection,
body.chat-fullscreen-open #membersSection,
body.chat-fullscreen-open #ownerSection,
body.chat-fullscreen-open .neon-bg {
  visibility: hidden !important;
  pointer-events: none !important;
}

body.chat-fullscreen-open .leaflet-pane,
body.chat-fullscreen-open .leaflet-top,
body.chat-fullscreen-open .leaflet-bottom,
body.chat-fullscreen-open .leaflet-control-container {
  visibility: hidden !important;
  pointer-events: none !important;
}

.chat-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse-dot 1.6s infinite;
}

@keyframes pulse-dot {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.chat-live-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
}

.chat-messages {
  flex: 1 1 auto;
  background: #0a0c10;
  border-radius: 14px;
  padding: 1rem;
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.65rem;
  scroll-behavior: smooth;
  isolation: isolate;
}

.chat-messages > :not(.msg):not(.empty-chat) {
  display: none !important;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.msg {
  position: relative;
  margin-bottom: 0.75rem;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  max-width: 88%;
  word-break: break-word;
  font-size: 0.92rem;
  animation: msg-in 0.28s ease;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg .msg-author {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 0.3rem;
  color: #00bfff;
}

.msg.you .msg-author {
  color: #7dd3fc;
}

.msg .msg-text {
  display: block;
  line-height: 1.4;
}

.msg.you {
  background: linear-gradient(135deg, rgba(0, 191, 255, 0.28), rgba(0, 140, 200, 0.18));
  border: 1px solid rgba(0, 191, 255, 0.45);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.msg.other {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 4px;
}

.msg .time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.chat-quick button {
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 191, 255, 0.35);
  background: rgba(0, 191, 255, 0.08);
  color: #c8ecff;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.chat-quick button:hover {
  background: rgba(0, 191, 255, 0.2);
  transform: translateY(-1px);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #0a0c10;
  border: 1px solid rgba(0, 191, 255, 0.25);
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
}

.chat-form input {
  flex: 1;
  padding: 0.65rem 0.25rem;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 0.95rem;
}

.chat-form input::placeholder {
  color: #666;
}

.chat-form input:focus {
  outline: none;
}

.chat-form button {
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #00bfff, #0088cc);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 191, 255, 0.35);
  transition: transform 0.15s, filter 0.15s;
}

.chat-form button:hover {
  filter: brightness(1.08);
  transform: scale(1.03);
}

.chat-form button:active {
  transform: scale(0.98);
}

.empty-chat {
  color: #8a93a3;
  text-align: center;
  padding: 2.5rem 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.empty-chat strong {
  display: block;
  color: #00bfff;
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
}
