/* TB Market — floating community chat */
.market-community-chat {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 100050;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

.market-community-chat__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 18px 0 14px;
  border: 1px solid rgba(129, 186, 255, 0.28);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(124, 58, 237, 0.9));
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.market-community-chat__toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 48px rgba(37, 99, 235, 0.35);
}

.market-community-chat__toggle-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1.1rem;
}

.market-community-chat.is-open .market-community-chat__toggle {
  border-radius: 16px 16px 8px 8px;
}

.market-community-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid rgba(129, 186, 255, 0.22);
  background: linear-gradient(180deg, rgba(14, 22, 42, 0.98), rgba(8, 13, 26, 0.98));
  box-shadow: 0 28px 64px rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s;
  pointer-events: none;
}

.market-community-chat.is-open .market-community-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.market-community-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.market-community-chat__head strong {
  display: block;
  font-size: 0.95rem;
}

.market-community-chat__head small {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.4;
}

.market-community-chat__close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 1.1rem;
}

.market-community-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.market-community-chat__empty {
  margin: auto 0;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 24px 12px;
}

.market-community-chat__bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 6px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.market-community-chat__bubble.is-mine {
  align-self: flex-end;
  border-radius: 14px 14px 6px 14px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(79, 70, 229, 0.28));
  border-color: rgba(96, 165, 250, 0.25);
}

.market-community-chat__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.68rem;
  color: #94a3b8;
}

.market-community-chat__meta strong {
  color: #e2e8f0;
  font-size: 0.72rem;
}

.market-community-chat__badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.market-community-chat__text {
  font-size: 0.86rem;
  line-height: 1.45;
  color: #f1f5f9;
  white-space: pre-wrap;
  word-break: break-word;
}

.market-community-chat__foot {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.market-community-chat__form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.market-community-chat__form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  font: inherit;
  font-size: 0.86rem;
}

.market-community-chat__form textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.market-community-chat__send {
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.market-community-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.market-community-chat__login {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  text-align: center;
}

.market-community-chat__login a {
  color: #93c5fd;
}

.market-community-chat__error {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: #fca5a5;
  min-height: 1em;
}

@media (max-width: 900px) {
  .market-community-chat {
    right: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }

  .market-community-chat__toggle-label {
    display: none;
  }

  .market-community-chat__toggle {
    width: 56px;
    height: 56px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .market-community-chat.is-open .market-community-chat__toggle {
    border-radius: 50%;
  }

  .market-community-chat__panel {
    width: min(360px, calc(100vw - 24px));
    height: min(460px, calc(100vh - 160px));
  }
}
