/* Global floating messages dock (Messenger-style popup, V1 local storage). */

.app-msg-dock {
  position: fixed;
  /* Align with notifications dock: same bottom baseline, message button sits to its left. */
  right: calc(clamp(1rem, 4vw, 1.35rem) + 12.2rem);
  bottom: clamp(1rem, 4vw, 1.35rem);
  z-index: 1210;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}

.app-msg-panel {
  width: min(100vw - 2rem, 420px);
  height: min(72vh, 560px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(165deg, rgba(28, 35, 48, 0.98) 0%, rgba(16, 20, 28, 0.99) 100%);
  box-shadow:
    0 10px 42px rgba(0, 0, 0, 0.58),
    0 2px 10px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.24s ease;
}

.app-msg-panel.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.app-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.78rem 0.9rem 0.66rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-msg-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: rgba(245, 248, 252, 0.98);
}

.app-msg-close {
  border: 0;
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(210, 221, 239, 0.95);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.app-msg-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.app-msg-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(145px, 42%) minmax(0, 1fr);
}

.app-msg-list {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.17);
  margin: 0;
  padding: 0.42rem;
  list-style: none;
}

.app-msg-list-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin: 0 0 0.38rem;
}

.app-msg-list-btn {
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.56rem;
  border: 0;
  background: transparent;
  color: rgba(230, 238, 250, 0.96);
  text-align: left;
  cursor: pointer;
}

.app-msg-list-item.is-active {
  border-color: rgba(110, 176, 255, 0.38);
  background: rgba(110, 176, 255, 0.12);
}

.app-msg-list-name {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 650;
}

.app-msg-list-preview {
  margin: 0.14rem 0 0;
  font-size: 0.66rem;
  color: rgba(154, 170, 192, 0.94);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-msg-list-unread {
  display: inline-block;
  margin-top: 0.22rem;
  font-size: 0.62rem;
  color: rgba(255, 188, 188, 0.98);
  font-weight: 650;
}

.app-msg-thread {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
}

.app-msg-thread-head {
  padding: 0.58rem 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
  font-weight: 650;
  color: rgba(226, 236, 250, 0.98);
}

.app-msg-thread-scroll {
  min-height: 0;
  overflow-y: auto;
  padding: 0.6rem 0.58rem;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.app-msg-bubble {
  max-width: 88%;
  padding: 0.46rem 0.52rem;
  border-radius: 11px;
  font-size: 0.74rem;
  line-height: 1.35;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-msg-bubble--mine {
  margin-left: auto;
  background: linear-gradient(180deg, rgba(110, 176, 255, 0.32) 0%, rgba(54, 98, 166, 0.38) 100%);
  border-color: rgba(110, 176, 255, 0.36);
  color: rgba(236, 244, 255, 0.98);
}

.app-msg-bubble--theirs {
  margin-right: auto;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(226, 234, 248, 0.96);
}

.app-msg-bubble-time {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.6rem;
  color: rgba(158, 172, 194, 0.92);
}

.app-msg-compose {
  display: flex;
  gap: 0.36rem;
  padding: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-msg-input {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
  color: rgba(234, 242, 252, 0.98);
  padding: 0.44rem 0.52rem;
  font: inherit;
  font-size: 0.74rem;
}

.app-msg-send {
  border: 1px solid rgba(110, 176, 255, 0.34);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(110, 176, 255, 0.22) 0%, rgba(42, 74, 124, 0.34) 100%);
  color: rgba(230, 240, 255, 0.98);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 0.62rem;
  cursor: pointer;
}

.app-msg-fab {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(130% 110% at 25% 15%, rgba(110, 176, 255, 0.36) 0%, rgba(110, 176, 255, 0.06) 50%, transparent 100%),
    linear-gradient(170deg, rgba(28, 38, 52, 0.9) 0%, rgba(14, 18, 24, 0.94) 100%);
  color: rgba(236, 243, 252, 0.98);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.44),
    0 2px 10px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.11);
}

.app-msg-fab:hover {
  transform: translateY(-2px) scale(1.03);
}

.app-msg-badge {
  position: absolute;
  top: -0.16rem;
  right: -0.15rem;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff6b7a 0%, #e84a5e 100%);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.28rem;
}

.app-msg-fab-wrap {
  position: relative;
}

.app-msg-empty {
  margin: 0;
  padding: 0.9rem 0.7rem;
  font-size: 0.74rem;
  color: rgba(160, 174, 194, 0.9);
}

@media (max-width: 760px) {
  .app-msg-dock {
    right: calc(clamp(1rem, 4vw, 1.35rem) + 10.4rem);
  }

  .app-msg-panel {
    width: min(100vw - 1rem, 430px);
    height: min(78vh, 560px);
  }
}
