/* 首頁會員聊天浮窗：對齊 ix9 藍金主題（theme-blue-gold） */
.chat-float-fab,
.chat-float {
  --cf-bg: var(--color-bg, #081223);
  --cf-nav: var(--color-nav, #0b1833);
  --cf-gold: var(--color-btn, #c9a35a);
  --cf-gold2: var(--ix9-gold-200, #e9d29a);
  --cf-ink: #0d2348;
  --cf-txt: var(--color-w100, #fff);
  --cf-muted: var(--color-w65, rgba(255, 255, 255, 0.65));
  --cf-dim: var(--color-w25, rgba(255, 255, 255, 0.25));
  --cf-line: rgba(215, 177, 106, 0.22);
  --cf-line-soft: rgba(255, 255, 255, 0.1);
  --cf-gold-grad: linear-gradient(135deg, #ddc38a 0%, #b48943 100%);
}

.chat-float-fab {
  position: fixed;
  z-index: 1030;
  right: 20px;
  bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 14px;
  border: 1px solid rgba(241, 214, 153, 0.42);
  border-radius: 8px;
  color: var(--cf-ink);
  background: var(--cf-gold-grad);
  box-shadow: 0 6px 18px rgba(181, 140, 66, 0.34);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chat-float-fab:hover {
  background: linear-gradient(135deg, #ead9a8 0%, #c49a52 100%);
  box-shadow: 0 10px 24px rgba(191, 149, 74, 0.45);
}

.chat-float-fab:active {
  transform: scale(0.97);
}

.chat-float-fab i {
  font-size: 18px;
}

.chat-float-fab:focus-visible {
  outline: 2px solid var(--cf-gold2);
  outline-offset: 3px;
}

.chat-float[hidden] {
  display: none !important;
}

.chat-float.is-open {
  display: block;
}

.chat-float__backdrop {
  display: none;
}

.chat-float__panel {
  position: fixed;
  z-index: 4200;
  right: 20px;
  bottom: 80px;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(560px, calc(100dvh - 120px));
  overflow: hidden;
  border-radius: 16px;
  color: var(--cf-txt);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)), var(--cf-nav);
  border: 1px solid var(--cf-line);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(248, 230, 184, 0.12);
}

.chat-float__head {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--cf-txt);
  background: rgba(8, 18, 35, 0.55);
  border-bottom: 1px solid var(--cf-line-soft);
}

.chat-float__head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chat-float__head h2 i {
  color: var(--cf-gold2);
  font-size: 15px;
}

.chat-float__close {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--cf-muted);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chat-float__close:hover,
.chat-float__close:active {
  color: #fff;
  background: rgba(215, 177, 106, 0.2);
  border-color: rgba(215, 177, 106, 0.4);
}

.chat-float__close i {
  pointer-events: none;
}

.chat-float__welcome {
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--cf-muted);
  background: rgba(215, 177, 106, 0.08);
  border-bottom: 1px solid var(--cf-line);
}

.chat-float__log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  background: rgba(0, 0, 0, 0.18);
}

.chat-float__empty {
  margin: 24px 0 0;
  text-align: center;
  color: var(--cf-dim);
  font-size: 14px;
}

.chat-float__msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 86%;
  margin: 0 0 10px;
}

.chat-float__msg--own {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-float__msg--follow {
  margin-top: -6px;
}

.chat-float__msg--follow .chat-float__meta {
  display: none;
}

.chat-float__msg--follow .chat-float__avatar img {
  visibility: hidden;
}

.chat-float__avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--cf-line);
}

.chat-float__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-float__body {
  min-width: 0;
  flex: 1;
}

.chat-float__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 3px;
  min-width: 0;
  font-size: 12px;
  color: var(--cf-muted);
}

.chat-float__msg--own .chat-float__meta {
  justify-content: flex-end;
}

.chat-float__vip {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--cf-gold2);
  letter-spacing: 0.02em;
}

.chat-float__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-float__bubble {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--cf-line-soft);
  color: var(--cf-txt);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-float__msg--own .chat-float__bubble {
  color: var(--cf-ink);
  background: var(--cf-gold-grad);
  border-color: rgba(241, 214, 153, 0.35);
}

.chat-float__time {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  opacity: 0.72;
}

.chat-float__status {
  min-height: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--cf-muted);
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid var(--cf-line-soft);
}

.chat-float__status:empty {
  display: none;
}

.chat-float__status p {
  margin: 0 0 6px;
}

.chat-float__status p:last-child {
  margin-bottom: 0;
}

.chat-float__status .chat-float__bar {
  height: 6px;
  margin: 8px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(215, 177, 106, 0.16);
}

.chat-float__status .chat-float__bar > i {
  display: block;
  height: 100%;
  background: var(--cf-gold-grad);
}

.chat-float__status .chat-float__login {
  display: inline-flex;
  margin: 8px 0 10px;
  padding: 6px 12px;
  border: 1px solid rgba(241, 214, 153, 0.42);
  border-radius: 8px;
  color: var(--cf-ink);
  background: var(--cf-gold-grad);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.chat-float__status .chat-float__login:hover {
  background: linear-gradient(135deg, #ead9a8 0%, #c49a52 100%);
}

.chat-float__composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: rgba(8, 18, 35, 0.55);
  border-top: 1px solid var(--cf-line-soft);
}

.chat-float__input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(215, 177, 106, 0.28);
  border-radius: 10px;
  color: var(--cf-txt);
  background: rgba(255, 255, 255, 0.05);
  font-size: 15px;
  outline: none;
  caret-color: #d7b16a;
}

.chat-float__input::placeholder {
  color: var(--cf-dim);
}

.chat-float__input:focus {
  border-color: rgba(215, 177, 106, 0.55);
  background: rgba(255, 255, 255, 0.07);
}

.chat-float__input:disabled {
  background: rgba(255, 255, 255, 0.03);
  color: var(--cf-dim);
}

.chat-float__input:-webkit-autofill,
.chat-float__input:-webkit-autofill:hover,
.chat-float__input:-webkit-autofill:focus {
  -webkit-text-fill-color: #fff;
  caret-color: #d7b16a;
  transition: background-color 9999s ease-out;
}

.chat-float__send {
  min-width: 64px;
  height: 40px;
  border: 1px solid rgba(241, 214, 153, 0.42);
  border-radius: 10px;
  color: var(--cf-ink);
  background: var(--cf-gold-grad);
  font-weight: 700;
  cursor: pointer;
}

.chat-float__send:hover:not(:disabled) {
  background: linear-gradient(135deg, #ead9a8 0%, #c49a52 100%);
}

.chat-float__send:disabled {
  color: var(--cf-dim);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--cf-line-soft);
  cursor: default;
}

@media (max-width: 767px) {
  .chat-float-fab {
    right: 14px;
    bottom: calc(var(--lux-bottom-nav-offset, 80px) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  body.chat-float-open .chat-float-fab {
    display: none;
  }

  .chat-float.is-open .chat-float__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 4190;
    background: rgba(0, 0, 0, 0.56);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
  }

  .chat-float__panel {
    right: 10px;
    left: 10px;
    width: auto;
    height: auto;
    bottom: calc(var(--lux-bottom-nav-offset, 80px) + env(safe-area-inset-bottom, 0px) + 10px);
    top: max(12px, env(safe-area-inset-top, 0px));
  }

  body.chat-float-open {
    overflow: hidden;
  }
}
