.dm-page {
  display: grid;
  grid-template-columns: minmax(15.5rem, 18rem) minmax(0, 1fr);
  height: calc(100vh - var(--header-height));
  min-height: 36rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0, rgba(215, 47, 72, 0.035), transparent 28rem),
    rgba(255, 253, 253, 0.72);
}

.dm-inbox {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 1.25rem 0.9rem 1rem;
  background:
    radial-gradient(circle at 0 0, rgba(215, 47, 72, 0.045), transparent 14rem),
    rgba(250, 247, 247, 0.66);
  border-right: 1px solid var(--color-border-subtle);
}

.dm-thread__header,
.dm-person,
.dm-composer__actions {
  display: flex;
  align-items: center;
}

.dm-attach-button,
.dm-send-button,
.dm-lune-toggle,
.dm-conversation {
  border: 0;
  cursor: pointer;
}

.dm-attach-button {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(77, 32, 40, 0.07);
  border-radius: 0.7rem;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.dm-attach-button:hover {
  color: var(--color-accent);
  background: #ffffff;
  border-color: rgba(215, 47, 72, 0.14);
  transform: translateY(-1px);
}

.dm-attach-button .icon {
  width: 1rem;
  height: 1rem;
}

.dm-search {
  display: flex;
  min-height: 2.45rem;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0.15rem 0.85rem;
  padding: 0 0.82rem;
  color: var(--color-text-muted);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.62), rgba(245, 239, 240, 0.56));
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(77, 32, 40, 0.055), 0 0.35rem 1rem rgba(77, 32, 40, 0.025);
  transition: background 160ms ease, box-shadow 180ms ease, transform 160ms ease;
}

.dm-search:focus-within {
  color: var(--color-accent);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(215, 47, 72, 0.13), 0 0 0 0.22rem rgba(215, 47, 72, 0.045), 0 0.55rem 1.25rem rgba(77, 32, 40, 0.045);
  transform: translateY(-1px);
}

.dm-search .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.dm-search input {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--color-text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.8rem;
}

.dm-search input::placeholder {
  color: var(--color-text-muted);
}

.dm-conversation-list {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 0;
  padding: 0.05rem 0.15rem 0.5rem;
  overflow-y: auto;
  scrollbar-color: rgba(117, 100, 104, 0.2) transparent;
  scrollbar-width: thin;
}

.dm-conversation {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.72rem;
  min-height: 3.75rem;
  padding: 0.65rem 0.7rem;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 1rem;
  text-align: left;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dm-conversation.has-unread {
  color: var(--color-text);
  background:
    radial-gradient(circle at 14% 50%, rgba(235, 82, 106, 0.13), transparent 44%),
    linear-gradient(105deg, rgba(255, 251, 252, 0.86), rgba(255, 255, 255, 0.48));
  border-color: rgba(215, 47, 72, 0.08);
  box-shadow:
    0 0.7rem 1.7rem rgba(191, 54, 78, 0.09),
    inset 0 0 0 1px rgba(255, 255, 255, 0.66);
  animation: dm-unread-glow 3.6s ease-in-out infinite;
}

.dm-conversation.has-unread .dm-conversation__name {
  color: #4e2932;
  font-weight: 710;
}

.dm-conversation.has-unread .dm-avatar {
  box-shadow:
    0 0 0 0.2rem rgba(255, 255, 255, 0.78),
    0 0 1.05rem rgba(215, 47, 72, 0.2);
}

.dm-conversation[hidden] {
  display: none;
}

.dm-conversation:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.62);
  transform: translateY(-1px);
}

.dm-conversation.is-active {
  color: var(--color-text);
  background: rgba(77, 32, 40, 0.045);
  border-color: transparent;
  box-shadow: none;
}

.dm-avatar {
  --avatar-color: #244f72;
  --avatar-surface: #dceaf3;
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  place-items: center;
  color: var(--avatar-color);
  background: var(--avatar-surface);
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  font-size: 0.64rem;
  font-weight: 660;
  letter-spacing: -0.01em;
}

.dm-avatar--violet {
  --avatar-color: #523c7a;
  --avatar-surface: #e8e1f1;
}

.dm-avatar--amber {
  --avatar-color: #6e4b1e;
  --avatar-surface: #f1e7d2;
}

.dm-avatar--mint {
  --avatar-color: #275d4a;
  --avatar-surface: #dcece5;
}

.dm-avatar--lune,
.mention-option__icon--lune {
  position: relative;
  color: transparent;
  background: conic-gradient(from 20deg, #8f1830, #d52f48, #ff8e84, #f3c4ba, #bd2340, #8f1830);
  box-shadow: 0 0 0.7rem rgba(215, 47, 72, 0.16);
}

.dm-avatar--lune::after,
.mention-option__icon--lune::after {
  position: absolute;
  inset: 0.27rem;
  content: "";
  background: #fffdfd;
  border-radius: inherit;
}

.dm-conversation__name {
  overflow: hidden;
  color: inherit;
  font-size: 0.8rem;
  font-weight: 670;
  letter-spacing: -0.012em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-thread {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: rgba(255, 254, 254, 0.78);
}

.dm-thread__header {
  min-height: 4.75rem;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1.25rem, 4vw, 2.75rem);
  background: rgba(255, 254, 254, 0.74);
  border-bottom: 1px solid var(--color-border-subtle);
  backdrop-filter: blur(16px);
}

.dm-person {
  min-width: 0;
  gap: 0.78rem;
}

.dm-avatar--thread {
  width: 2.55rem;
  height: 2.55rem;
  font-size: 0.73rem;
}

.dm-person > div {
  min-width: 0;
}

.dm-person h2 {
  margin: 0;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 690;
  letter-spacing: -0.018em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-person p {
  display: flex;
  align-items: center;
  gap: 0.36rem;
  margin: 0.24rem 0 0;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-presence {
  width: 0.38rem;
  height: 0.38rem;
  flex: 0 0 auto;
  background: #c8bec0;
  border-radius: 50%;
}

.dm-presence.is-online {
  background: #61b986;
  box-shadow: 0 0 0 0.18rem rgba(97, 185, 134, 0.12);
}

.dm-messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 1.4rem;
  padding: 2rem clamp(1.5rem, 6.5vw, 5.25rem) 2.75rem;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-color: rgba(117, 100, 104, 0.2) transparent;
  scrollbar-width: thin;
}

.dm-day-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.15rem 0 0.55rem;
  color: var(--color-text-muted);
  font-size: 0.66rem;
  font-weight: 660;
}

.dm-day-divider::before,
.dm-day-divider::after {
  height: 1px;
  flex: 1;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(77, 32, 40, 0.08));
}

.dm-day-divider::after {
  background: linear-gradient(90deg, rgba(77, 32, 40, 0.08), transparent);
}

.dm-message {
  display: flex;
  width: 100%;
  max-width: 42rem;
  align-items: flex-start;
  gap: 0.7rem;
  margin-right: auto;
}

.dm-message--mine {
  justify-content: flex-end;
  margin-right: 0;
  margin-left: auto;
}

.dm-avatar--message {
  width: 1.7rem;
  height: 1.7rem;
  margin-top: 0.08rem;
  font-size: 0.52rem;
}

.dm-message__content {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.38rem;
  max-width: min(34rem, 78%);
}

.dm-message--mine .dm-message__content {
  align-items: flex-end;
}

.dm-message__content p {
  margin: 0;
  padding: 0.96rem 1.15rem;
  color: var(--color-text);
  background: rgba(251, 248, 248, 0.92);
  border: 1px solid rgba(77, 32, 40, 0.07);
  border-radius: 1.1rem 1.1rem 1.1rem 0.35rem;
  box-shadow: 0 0.45rem 1.25rem rgba(77, 32, 40, 0.035), inset 0 1px rgba(255, 255, 255, 0.86);
  font-size: 0.82rem;
  line-height: 1.55;
}

.dm-message--mine .dm-message__content p {
  background: linear-gradient(145deg, rgba(250, 220, 224, 0.76), rgba(255, 246, 246, 0.94));
  border-color: rgba(215, 47, 72, 0.1);
  border-radius: 1.1rem 1.1rem 0.35rem 1.1rem;
}

.dm-message--lune .dm-message__content p {
  background: linear-gradient(145deg, rgba(255, 250, 250, 0.98), rgba(250, 235, 238, 0.78));
  border-color: rgba(215, 47, 72, 0.12);
  box-shadow: 0 0.65rem 1.8rem rgba(177, 48, 74, 0.06), inset 0 1px rgba(255, 255, 255, 0.9);
}

.lune-chat-thinking {
  display: block;
  width: 1.8rem;
  height: 0.62rem;
  margin: 0.58rem 0.3rem;
  background: radial-gradient(circle, #cf3653 0 0.16rem, transparent 0.18rem) 0 50% / 0.62rem 0.62rem repeat-x;
  animation: lune-chat-pulse 900ms ease-in-out infinite alternate;
}

@keyframes lune-chat-pulse {
  from { opacity: 0.35; transform: translateY(0); }
  to { opacity: 0.95; transform: translateY(-0.08rem); }
}

.dm-message__content p + p {
  border-top-left-radius: 0.72rem;
}

.dm-message--mine .dm-message__content p + p {
  border-top-right-radius: 0.72rem;
}

.dm-compose-area {
  position: relative;
  z-index: 2;
  padding: 1.2rem clamp(1.5rem, 6.5vw, 5.25rem) 1.5rem;
  background: linear-gradient(180deg, rgba(255, 253, 253, 0), rgba(255, 253, 253, 0.92) 32%, rgba(255, 253, 253, 0.98));
}

.dm-composer {
  position: relative;
  width: 100%;
  max-width: 44rem;
  margin-right: auto;
  margin-left: auto;
}

.mention-picker {
  position: absolute;
  right: auto;
  bottom: calc(100% + 0.65rem);
  left: 0;
  z-index: 12;
  display: grid;
  width: min(20rem, calc(100vw - 3rem));
  max-height: 18rem;
  gap: 0.18rem;
  padding: 0.45rem;
  overflow-y: auto;
  background: rgba(255, 253, 253, 0.98);
  border: 1px solid rgba(77, 32, 40, 0.09);
  border-radius: 1rem;
  box-shadow: 0 1rem 2.8rem rgba(61, 29, 35, 0.15), inset 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.mention-picker[hidden] {
  display: none;
}

.mention-option {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.55rem;
  color: var(--color-text-secondary);
  background: transparent;
  border: 0;
  border-radius: 0.72rem;
  cursor: pointer;
  text-align: left;
}

.mention-option:hover,
.mention-option.is-highlighted {
  color: var(--color-text);
  background: rgba(215, 47, 72, 0.065);
}

.mention-option__icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: #244f72;
  background: #dceaf3;
  border-radius: 0.62rem;
  font-size: 0.57rem;
  font-weight: 740;
}

.mention-option__icon--violet { color: #523c7a; background: #e8e1f1; }
.mention-option__icon--amber { color: #6e4b1e; background: #f1e7d2; }
.mention-option__icon--mint { color: #275d4a; background: #dcece5; }
.mention-option__icon--page { color: #a13e60; background: #f4e4eb; }

.mention-option > span:last-child {
  display: grid;
  min-width: 0;
  gap: 0.08rem;
}

.mention-option strong {
  overflow: hidden;
  font-size: 0.75rem;
  font-weight: 690;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option small {
  color: var(--color-text-muted);
  font-size: 0.64rem;
}

.message-mention {
  display: inline-block;
  padding: 0.03rem 0.3rem;
  color: #ad3659;
  background: rgba(215, 47, 72, 0.09);
  border-radius: 0.38rem;
  font-weight: 690;
}

.dm-lune-toggle {
  position: relative;
  display: block;
  width: 2.9rem;
  height: 1.75rem;
  flex: 0 0 auto;
  padding: 0;
  background: rgba(77, 32, 40, 0.055);
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(77, 32, 40, 0.055);
  transition: background 220ms ease, box-shadow 220ms ease, transform 180ms ease;
}

.dm-lune-toggle:hover {
  background: rgba(77, 32, 40, 0.075);
  transform: translateY(-1px);
}

.dm-lune-ring {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  background: conic-gradient(from 20deg, #8f1830, #d52f48, #ff8e84, #f3c4ba, #bd2340, #8f1830);
  border-radius: 50%;
  opacity: 0.66;
  transition: opacity 220ms ease, box-shadow 220ms ease, transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dm-lune-ring::after {
  position: absolute;
  inset: 0.2rem;
  content: "";
  background: #fffdfd;
  border-radius: inherit;
}

.dm-compose-area.is-lune-active .dm-lune-toggle {
  background: linear-gradient(90deg, rgba(215, 47, 72, 0.1), rgba(239, 138, 127, 0.15));
  box-shadow: inset 0 0 0 1px rgba(215, 47, 72, 0.12);
}

.dm-compose-area.is-lune-active .dm-lune-ring {
  opacity: 1;
  box-shadow: 0 0 0.65rem rgba(215, 47, 72, 0.24);
  transform: translateX(1.15rem) rotate(1turn);
}

.dm-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
  min-height: 4.25rem;
  padding: 0.82rem 0.82rem 0.82rem 1.15rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(77, 32, 40, 0.085);
  border-radius: 1.2rem;
  box-shadow: 0 0.7rem 2rem rgba(77, 32, 40, 0.055), inset 0 1px rgba(255, 255, 255, 0.94);
  transition: border-color 180ms ease, box-shadow 220ms ease;
}

.dm-composer:has(textarea:focus) {
  border-color: rgba(215, 47, 72, 0.16);
  box-shadow: 0 0 0 0.24rem rgba(215, 47, 72, 0.045), 0 0.9rem 2.4rem rgba(77, 32, 40, 0.07);
}

.dm-composer textarea {
  width: 100%;
  min-height: 2.2rem;
  max-height: 7rem;
  padding: 0.5rem 0;
  resize: none;
  overflow-y: auto;
  color: var(--color-text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.dm-composer textarea::placeholder {
  color: var(--color-text-muted);
}

.dm-composer__actions {
  gap: 0.45rem;
}

.dm-attach-button {
  background: transparent;
  border-color: transparent;
}

.dm-send-button {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  padding: 0;
  color: #ffffff;
  background: var(--gradient-accent);
  border-radius: 0.78rem;
  box-shadow: 0 0.5rem 1.2rem rgba(173, 23, 51, 0.17), inset 0 1px rgba(255, 255, 255, 0.24);
  transition: filter 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dm-send-button:hover {
  filter: saturate(1.06) brightness(1.04);
  box-shadow: 0 0.65rem 1.35rem rgba(173, 23, 51, 0.22), inset 0 1px rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.dm-send-button .icon {
  width: 1rem;
  height: 1rem;
}

@keyframes dm-unread-glow {
  0%,
  100% {
    box-shadow:
      0 0.55rem 1.4rem rgba(191, 54, 78, 0.07),
      inset 0 0 0 1px rgba(255, 255, 255, 0.62);
  }

  50% {
    box-shadow:
      0 0.8rem 2rem rgba(191, 54, 78, 0.14),
      inset 0 0 0 1px rgba(255, 255, 255, 0.76);
  }
}

@media (min-width: 80rem) {
  .dm-page {
    height: calc(100vh - 2.5rem - var(--header-height));
  }
}

@media (max-width: 46rem) {
  .dm-page {
    grid-template-columns: minmax(13.5rem, 15rem) minmax(0, 1fr);
  }

  .dm-inbox {
    padding-right: 0.65rem;
    padding-left: 0.65rem;
  }

  .dm-conversation {
    padding-right: 0.55rem;
    padding-left: 0.55rem;
  }

  .dm-thread__header,
  .dm-messages,
  .dm-compose-area {
    padding-right: 1rem;
    padding-left: 1rem;
  }
}

@media (max-width: 40rem) {
  .dm-page {
    display: block;
    height: auto;
    min-height: calc(100vh - var(--header-height));
    overflow: visible;
  }

  .dm-inbox {
    display: block;
    padding: 0.85rem 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--color-border-subtle);
  }

  .dm-search {
    margin-bottom: 0.65rem;
  }

  .dm-conversation-list {
    display: flex;
    gap: 0.45rem;
    padding-bottom: 0.15rem;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .dm-conversation {
    width: 11.5rem;
    min-height: 3.7rem;
    flex: 0 0 auto;
  }

  .dm-thread {
    min-height: 36rem;
  }

  .dm-message__content {
    max-width: 84%;
  }

}

@media (prefers-reduced-motion: reduce) {
  .dm-conversation.has-unread {
    animation: none;
  }
}
.message-attachment { display: block; width: fit-content; max-width: 18rem; margin: .25rem 0; padding: .55rem .7rem; overflow: hidden; color: #8f2942; background: rgba(255,255,255,.76); border: 1px solid rgba(143,41,66,.12); border-radius: .6rem; font-size: .78rem; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.message-attachment-pending { grid-column: 1 / -1; display: flex; gap: .35rem; padding: .1rem .25rem; }
.message-attachment-pending span { max-width: 12rem; padding: .3rem .5rem; overflow: hidden; color: var(--color-text-secondary); background: rgba(143,41,66,.06); border-radius: .45rem; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
