/* Chat premium refresh - May 2026 */

body.page-chats,
body.page-chat-detail {
  --chat-ink: var(--color-text);
  --chat-muted: var(--color-text-secondary);
  --chat-primary: var(--color-primary);
  --chat-primary-strong: var(--color-primary-dark);
  --chat-accent: var(--color-accent);
  --chat-line: rgba(103, 58, 183, 0.12);
  --chat-surface: rgba(255, 255, 255, 0.94);
  --chat-shadow: 0 22px 48px rgba(67, 41, 128, 0.10);
  background:
    linear-gradient(135deg, rgba(103, 58, 183, 0.08), transparent 32%),
    linear-gradient(225deg, rgba(241, 165, 89, 0.14), transparent 30%),
    linear-gradient(180deg, #fcfbff 0%, #f8f4fd 48%, #f5f5fa 100%) !important;
}

/* Inbox */
body.page-chats .page-content {
  padding-top: calc(var(--navbar-height, 64px) + 18px);
  background: transparent !important;
}

body.page-chats .chats-layout {
  width: min(1240px, calc(100% - 28px));
  max-width: none;
}

body.page-chats .chats-shell {
  gap: 16px;
}

body.page-chats .chats-page-top,
body.page-chats .chats-control-panel,
body.page-chats .chats-list-panel {
  border: 1px solid var(--chat-line);
  background: var(--chat-surface);
  box-shadow: var(--chat-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.page-chats .chats-page-top {
  min-height: 210px;
  align-items: stretch;
  padding: clamp(20px, 3vw, 30px);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(246,250,252,0.92)),
    linear-gradient(135deg, rgba(86,52,166,0.12), rgba(11,135,147,0.1));
}

body.page-chats .chats-page-title-wrap {
  display: grid;
  align-content: center;
  gap: 12px;
}

body.page-chats .chats-page-title-wrap h1 {
  color: var(--chat-ink);
  font-size: clamp(2.3rem, 4vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

body.page-chats .chats-page-title-wrap p {
  max-width: 680px;
  margin: 0;
  color: rgba(23, 19, 33, 0.68);
  font-size: 15px;
  line-height: 1.9;
  font-weight: 700;
}

body.page-chats .chats-page-hero-tag,
body.page-chats .chats-results-count,
body.page-chats #chat-filters .filter-chip,
body.page-chats .chats-search-input {
  border-color: rgba(103, 58, 183, 0.12);
}

body.page-chats .chats-page-hero-tag {
  color: var(--chat-primary-strong);
  background: rgba(103, 58, 183, 0.08);
}

body.page-chats .chats-top-counters {
  min-width: 210px;
  align-content: center;
  align-items: center;
}

body.page-chats .chats-total-badge,
body.page-chats .chats-unread-badge {
  min-height: 42px;
  border-radius: 16px;
}

body.page-chats .chats-total-badge {
  min-width: 58px;
  background: linear-gradient(135deg, var(--chat-primary-strong), var(--chat-primary) 58%, var(--chat-accent));
}

body.page-chats .chats-unread-badge {
  color: var(--chat-primary-strong);
  background: rgba(103, 58, 183, 0.08);
  border-color: rgba(103, 58, 183, 0.14);
}

body.page-chats .chats-control-panel,
body.page-chats .chats-list-panel {
  border-radius: 24px;
  padding: 16px;
}

body.page-chats .chats-filter-head h3,
body.page-chats .thread-name {
  color: var(--chat-ink);
}

body.page-chats #chat-filters .filter-chip {
  min-height: 40px;
  color: var(--chat-muted);
  background: #fff;
}

body.page-chats #chat-filters .filter-chip.active {
  background: linear-gradient(135deg, var(--chat-primary-strong), var(--chat-primary) 60%, var(--chat-accent));
}

body.page-chats .chats-search-wrap {
  max-width: 760px;
}

body.page-chats .chats-search-input {
  height: 52px;
  border-radius: 16px;
  background: #fff;
  color: var(--chat-ink);
  font-weight: 750;
}

body.page-chats .chats-search-input:focus {
  border-color: rgba(103, 58, 183, 0.28);
  box-shadow: 0 0 0 4px rgba(103, 58, 183, 0.12);
}

body.page-chats .chat-thread-card {
  border-radius: 20px;
  border-color: rgba(44, 31, 78, 0.1);
  background: linear-gradient(180deg, #fff, #fbfcff);
  box-shadow: 0 14px 28px rgba(25, 20, 40, 0.06);
  overflow: visible;
  z-index: 0;
}

body.page-chats .chat-thread-card.unread {
  border-color: rgba(86, 52, 166, 0.24);
  background:
    radial-gradient(circle at top right, rgba(86, 52, 166, 0.13), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8f5ff 52%, #f4fbff 100%);
  box-shadow: 0 22px 40px rgba(63, 35, 132, 0.13);
}

/* المفضّلة (ذات الأهمية) تأخذ تمييزًا ذهبيًا — وغير المقروء يبقى الأولوية. */
body.page-chats .chat-thread-card.favorite:not(.unread) {
  border-color: rgba(245, 158, 11, 0.42);
  background:
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.10), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fffdf5 100%);
}
body.page-chats .chat-thread-card.favorite:not(.unread)::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 14px;
  bottom: 14px;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fbbf24, #d97706);
  opacity: 1;
}

body.page-chats .chat-thread-card.promo-thread {
  border-color: rgba(124, 58, 237, 0.22);
  background:
    linear-gradient(135deg, rgba(245, 243, 255, 0.92), rgba(255, 255, 255, 0.98) 58%),
    linear-gradient(180deg, rgba(255, 251, 235, 0.55), rgba(255, 255, 255, 0));
}

body.page-chats .chat-thread-card.promo-thread::before {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  opacity: 1;
}

body.page-chats .chat-thread-card.promo-thread .thread-preview-pill.accent-violet {
  color: #5b21b6;
  background: linear-gradient(135deg, #ede9fe, #f5f3ff);
  border-color: #ddd6fe;
}

body.page-chats .chat-thread-card.menu-open {
  z-index: 40;
}

body.page-chats .chat-thread-card::after {
  display: none;
}

body.page-chats .chat-thread-card::before {
  top: 14px;
  bottom: 14px;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--chat-primary), var(--chat-accent));
}

body.page-chats .chat-thread-card.unread::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 12px;
  bottom: 12px;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6d44d7 0%, #4d9af8 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.92), 0 0 18px rgba(109, 68, 215, 0.28);
  opacity: 1;
}

body.page-chats .chat-thread-card:not(.unread)::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  opacity: 0.38;
}

body.page-chats .chat-thread-card:hover {
  transform: translateY(-3px);
  border-color: rgba(103, 58, 183, 0.18);
  box-shadow: 0 24px 44px rgba(25, 20, 40, 0.12);
}

body.page-chats .chat-thread-card.unread:hover {
  border-color: rgba(86, 52, 166, 0.34);
  box-shadow: 0 28px 48px rgba(63, 35, 132, 0.18);
}

body.page-chats .thread-avatar {
  border-radius: 18px;
  background: linear-gradient(135deg, var(--chat-primary-strong), var(--chat-primary));
}

body.page-chats .thread-role-chip,
body.page-chats .thread-preview-pill,
body.page-chats .thread-label-chip,
body.page-chats .thread-favorite-chip,
body.page-chats .thread-unread-badge {
  border-radius: 999px;
  font-weight: 850;
}

body.page-chats .chat-thread-card.unread .thread-name {
  color: var(--chat-primary-strong);
}

body.page-chats .chat-thread-card.unread .thread-subtitle,
body.page-chats .chat-thread-card.unread .thread-last-msg {
  color: rgba(23, 19, 33, 0.84);
}

body.page-chats .chat-thread-card.unread .thread-last-msg {
  font-weight: 800;
}

body.page-chats .chat-thread-card.unread .thread-time {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(86, 52, 166, 0.1);
  color: var(--chat-primary-strong);
}

body.page-chats .thread-open-hint {
  margin-inline-start: auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--chat-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

body.page-chats .chat-thread-card.unread .thread-open-hint {
  background: linear-gradient(135deg, var(--chat-primary-strong), var(--chat-primary) 65%, var(--chat-accent));
  box-shadow: 0 10px 20px rgba(50, 27, 105, 0.18);
}

@keyframes chatsUnreadPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.34);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

body.page-chats .thread-unread-dot {
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #19c37d 0%, #06b6d4 100%);
  border: 2px solid #fff;
  inset-inline-start: -4px;
  top: -4px;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

body.page-chats .chat-thread-card.unread .thread-unread-dot {
  animation: chatsUnreadPulse 1.8s infinite;
}

body.page-chats .thread-unread-badge {
  min-height: 28px;
  padding: 0 11px;
  background: linear-gradient(135deg, #ecfdf3 0%, #dff8ef 100%);
  border: 1px solid #9fdfbf;
  color: #0b7a63;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.12);
}

body.page-chats .thread-unread-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  margin-inline-end: 7px;
  flex-shrink: 0;
  opacity: 0.95;
}

body.page-chats .chats-thread-actions {
  z-index: 3;
}

body.page-chats .empty-hint,
body.page-chat-detail .chat-state {
  border-color: rgba(103, 58, 183, 0.16);
  background: linear-gradient(180deg, #fff, #fbf9ff);
  color: var(--chat-muted);
}

body.page-chats .empty-icon,
body.page-chat-detail .chat-empty-icon {
  width: 62px;
  height: 62px;
  margin-inline: auto;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: var(--chat-primary);
  background: rgba(103, 58, 183, 0.08);
}

/* Conversation detail */
body.page-chat-detail #site-footer {
  display: none !important;
}

@media (min-width: 769px) {
  body.page-chat-detail #bottom-nav {
    display: none !important;
  }

  body.page-chat-detail .chat-detail-page {
    padding: 16px 12px 18px;
  }
}

body.page-chat-detail .chat-detail-page {
  min-height: calc(100vh - var(--navbar-height, 64px));
  background: transparent !important;
  padding: 16px 12px calc(var(--bottom-nav-height, 84px) + 14px);
}

body.page-chat-detail .chat-desktop-shell {
  width: min(1320px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

body.page-chat-detail .chat-desktop-sidebar,
body.page-chat-detail .chat-desktop-main-frame {
  min-height: calc(100vh - var(--navbar-height, 64px) - 36px);
  border: 1px solid var(--chat-line);
  background: var(--chat-surface);
  box-shadow: var(--chat-shadow);
  border-radius: 26px;
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.page-chat-detail .chat-desktop-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

body.page-chat-detail .chat-desktop-main-frame {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(247,249,252,0.95)),
    linear-gradient(135deg, rgba(86,52,166,0.05), rgba(11,135,147,0.05));
}

body.page-chat-detail .chat-header,
body.page-chat-detail .chat-member-card,
body.page-chat-detail .chat-messages-shell,
body.page-chat-detail .chat-input-wrap {
  margin: 0;
  border-color: rgba(44, 31, 78, 0.1);
  box-shadow: none;
}

body.page-chat-detail .chat-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.page-chat-detail .chat-header {
  position: static;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,251,255,0.95));
}

body.page-chat-detail .chat-header-main {
  align-items: flex-start;
  gap: 14px;
}

body.page-chat-detail .chat-peer-row {
  align-items: flex-start;
  gap: 11px;
}

body.page-chat-detail .chat-peer-info {
  display: grid;
  gap: 4px;
  width: 100%;
}

body.page-chat-detail .chat-peer-name-row {
  flex-wrap: wrap;
  row-gap: 6px;
}

body.page-chat-detail .chat-peer-avatar {
  border-radius: 50%;
  background: var(--nw-avatar-ring-gradient);
  color: var(--chat-primary-strong);
}

body.page-chat-detail .chat-peer-name,
body.page-chat-detail .chat-member-value {
  color: var(--chat-ink);
}

body.page-chat-detail .chat-peer-name {
  font-size: 18px;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

body.page-chat-detail .chat-peer-subtitle {
  margin-top: 2px;
  line-height: 1.65;
}

body.page-chat-detail .chat-peer-tags {
  margin-top: 6px;
}

body.page-chat-detail .chat-header-btn,
body.page-chat-detail .chat-back-btn,
body.page-chat-detail .chat-member-action {
  border-color: rgba(103, 58, 183, 0.14);
  color: var(--chat-primary-strong);
  background: rgba(255, 255, 255, 0.94);
}

body.page-chat-detail .chat-member-card {
  grid-template-columns: 1fr;
  border-radius: 18px;
  background: rgba(255,255,255,0.46);
}

body.page-chat-detail .chat-member-row-identity {
  display: none;
}

body.page-chat-detail .chat-member-row {
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(252,249,255,0.96));
}

body.page-chat-detail .chat-messages-shell {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(249,248,252,0.94));
}

body.page-chat-detail .chat-messages {
  width: min(100%, 920px);
  margin-inline: auto;
  padding: 22px 20px 20px;
  gap: 8px;
}

body.page-chat-detail .chat-day-divider span {
  background: rgba(255, 255, 255, 0.86);
  color: #6b6780;
  border-color: rgba(103, 58, 183, 0.10);
  box-shadow: 0 6px 16px rgba(31, 24, 51, 0.04);
}

body.page-chat-detail .msg-kind-badge.accent-violet {
  background: rgba(103, 58, 183, 0.10);
  border-color: rgba(103, 58, 183, 0.18);
  color: var(--chat-primary-strong);
}

body.page-chat-detail .msg-kind-badge.accent-amber {
  background: rgba(241, 165, 89, 0.14);
  border-color: rgba(241, 165, 89, 0.24);
  color: #a05d17;
}

body.page-chat-detail .msg-kind-badge.accent-teal {
  background: rgba(13, 148, 136, 0.10);
  border-color: rgba(13, 148, 136, 0.20);
  color: #0f766e;
}

body.page-chat-detail .msg-service-cta.theirs,
body.page-chat-detail .msg-payment-cta.theirs {
  background: linear-gradient(180deg, rgba(241, 165, 89, 0.12), rgba(255, 243, 224, 0.68));
  border-color: rgba(241, 165, 89, 0.24);
  color: var(--chat-primary-strong);
}

body.page-chat-detail .msg-bubble {
  width: fit-content;
  min-width: 0;
  max-width: min(62%, 560px);
  border-radius: 20px;
  border: 1px solid transparent;
  box-shadow: 0 8px 18px rgba(25, 20, 40, 0.05);
  position: relative;
  padding: 11px 13px 9px;
}

body.page-chat-detail .msg-bubble-content {
  display: grid;
  gap: 8px;
}

body.page-chat-detail .msg-bubble-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

body.page-chat-detail .msg-bubble-head.is-actions-only {
  justify-content: flex-end;
}

body.page-chat-detail .msg-bubble-head .msg-badge-row {
  margin-bottom: 0;
  flex: 1;
}

body.page-chat-detail .msg-row {
  align-items: flex-end;
  margin: 2px 0;
}

body.page-chat-detail .msg-bubble-menu-btn {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(44, 31, 78, 0.08);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

body.page-chat-detail .msg-bubble-menu-btn:hover {
  transform: translateY(-1px);
}

body.page-chat-detail .msg-bubble.mine .msg-bubble-menu-btn {
  color: rgba(255,255,255,0.94);
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
}

body.page-chat-detail .msg-bubble.theirs .msg-bubble-menu-btn {
  color: var(--chat-primary-strong);
  background: rgba(103,58,183,0.04);
}

body.page-chat-detail .msg-bubble .msg-service-cta,
body.page-chat-detail .msg-bubble .msg-payment-cta {
  box-shadow: 0 10px 22px rgba(20, 18, 35, 0.08);
}

body.page-chat-detail .msg-bubble .msg-attachment-file,
body.page-chat-detail .msg-bubble .msg-attachment-audio {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
}

body.page-chat-detail .msg-bubble.mine {
  border-color: rgba(255,255,255,0.08);
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.18), transparent 28%),
    linear-gradient(180deg, #7d6ccb 0%, #6d5bb8 56%, #624fa7 100%);
  color: #fff;
  box-shadow: 0 16px 28px rgba(81, 45, 136, 0.18);
}

body.page-chat-detail .msg-bubble.theirs {
  border: 1px solid rgba(103, 58, 183, 0.08);
  background: rgba(255,255,255,0.94);
  color: var(--chat-ink);
}

body.page-chat-detail .msg-row.is-system {
  justify-content: center;
  position: relative;
  margin: 22px 0 12px;
}

body.page-chat-detail .msg-row.is-system::before,
body.page-chat-detail .msg-row.is-system::after {
  content: "";
  position: absolute;
  top: 24px;
  width: calc(50% - 150px);
  border-top: 1px solid rgba(103, 58, 183, 0.06);
}

body.page-chat-detail .msg-row.is-system::before {
  inset-inline-start: 0;
}

body.page-chat-detail .msg-row.is-system::after {
  inset-inline-end: 0;
}

body.page-chat-detail .msg-row.is-system .msg-bubble {
  min-width: 0;
  max-width: min(60%, 560px);
  padding: 14px 18px 12px;
  border: 1px solid rgba(103, 58, 183, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(251,248,255,0.96)),
    linear-gradient(135deg, rgba(103,58,183,0.04), rgba(241,165,89,0.05));
  box-shadow: 0 14px 28px rgba(31, 24, 51, 0.06);
}

body.page-chat-detail .msg-row.is-system.is-provider-reminder .msg-bubble {
  border-color: rgba(13, 148, 136, 0.22);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.99), rgba(240,253,250,0.95)),
    linear-gradient(135deg, rgba(13,148,136,0.08), rgba(255,255,255,0.94));
  box-shadow: 0 14px 28px rgba(13, 148, 136, 0.08);
}

body.page-chat-detail .msg-row.is-system.is-provider-reminder .msg-bubble::before,
body.page-chat-detail .msg-row.is-system.is-provider-notice .msg-bubble::before {
  content: "";
  position: absolute;
  inset-block: 14px;
  inset-inline-start: 0;
  width: 4px;
  border-radius: 999px;
}

body.page-chat-detail .msg-row.is-system.is-provider-reminder .msg-bubble::before {
  background: #0d9488;
}

body.page-chat-detail .msg-row.is-system.is-provider-notice .msg-bubble {
  border-color: rgba(241, 165, 89, 0.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.99), rgba(255,247,237,0.96)),
    linear-gradient(135deg, rgba(241,165,89,0.10), rgba(255,255,255,0.94));
  box-shadow: 0 14px 28px rgba(180, 83, 9, 0.08);
}

body.page-chat-detail .msg-row.is-system.is-provider-notice .msg-bubble::before {
  background: #d97706;
}

body.page-chat-detail .msg-row.is-system .msg-bubble-content {
  gap: 8px;
}

body.page-chat-detail .msg-row.is-system .msg-bubble-head {
  justify-content: center;
}

body.page-chat-detail .msg-row.is-system .msg-badge-row {
  justify-content: center;
  margin-bottom: 2px;
}

body.page-chat-detail .msg-row.is-system .msg-text {
  text-align: center;
  font-size: 13.5px;
  line-height: 1.8;
  font-weight: 600;
  color: #5f5871;
}

body.page-chat-detail .msg-row.is-system .msg-meta {
  justify-content: center;
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.68;
}

body.page-chat-detail .msg-row.is-system .msg-bubble-menu-btn {
  position: absolute;
  inset-inline-start: 12px;
  inset-block-start: 10px;
}

body.page-chat-detail .msg-row.is-system .msg-kind-badge.accent-violet {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.16);
  color: #0f766e;
}

body.page-chat-detail .msg-row.is-system .msg-kind-badge.accent-soft {
  background: rgba(103, 58, 183, 0.06);
  border-color: rgba(103, 58, 183, 0.12);
  color: var(--chat-primary-strong);
}

body.page-chat-detail .msg-row.is-system .msg-inline-link {
  color: var(--chat-primary-strong);
  background: linear-gradient(135deg, rgba(103,58,183,0.08), rgba(255,255,255,0.92));
  border-color: rgba(103,58,183,0.14);
  box-shadow: 0 8px 18px rgba(103,58,183,0.08);
}

body.page-chat-detail .msg-row.is-system .msg-inline-link:hover {
  background: linear-gradient(135deg, rgba(103,58,183,0.12), rgba(255,255,255,0.98));
  box-shadow: 0 12px 22px rgba(103,58,183,0.10);
}

body.page-chat-detail .msg-row.is-system .msg-inline-link-icon {
  background: rgba(103,58,183,0.10);
}

body.page-chat-detail .msg-text {
  font-size: 14.5px;
  line-height: 1.75;
  font-weight: 600;
  word-break: normal;
  overflow-wrap: anywhere;
}

body.page-chat-detail .msg-meta {
  width: 100%;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 6px;
  font-size: 10px;
  opacity: 0.72;
}

body.page-chat-detail .msg-bubble .msg-time,
body.page-chat-detail .msg-bubble .msg-read-state {
  font-weight: 700;
}

body.page-chat-detail .msg-kind-badge {
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.01em;
}

body.page-chat-detail .msg-bubble-menu-btn {
  opacity: 0;
}

body.page-chat-detail .msg-bubble:hover .msg-bubble-menu-btn,
body.page-chat-detail .msg-bubble:focus-within .msg-bubble-menu-btn {
  opacity: 1;
}

body.page-chat-detail .msg-bubble.mine .msg-service-cta,
body.page-chat-detail .msg-bubble.mine .msg-payment-cta {
  gap: 12px;
  padding: 12px 13px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.10));
  border-color: rgba(255,255,255,0.22);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.16),
    0 10px 22px rgba(49, 28, 92, 0.16);
}

body.page-chat-detail .msg-bubble.theirs .msg-service-cta,
body.page-chat-detail .msg-bubble.theirs .msg-payment-cta {
  border-radius: 16px;
  background: rgba(103,58,183,0.04);
  border-color: rgba(103,58,183,0.10);
}

body.page-chat-detail .msg-bubble.mine .msg-kind-badge.accent-soft {
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.96);
}

body.page-chat-detail .msg-bubble.mine .msg-service-cta-icon,
body.page-chat-detail .msg-bubble.mine .msg-payment-cta-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

body.page-chat-detail .msg-bubble.mine .msg-service-cta-title,
body.page-chat-detail .msg-bubble.mine .msg-payment-cta-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  color: #fff;
}

body.page-chat-detail .msg-bubble.mine .msg-service-cta-subtitle,
body.page-chat-detail .msg-bubble.mine .msg-payment-cta-subtitle {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.45;
  font-weight: 700;
  color: rgba(255,255,255,0.78);
}

body.page-chat-detail .msg-bubble.mine .msg-service-cta-arrow,
body.page-chat-detail .msg-bubble.mine .msg-payment-cta-arrow {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.92);
}

body.page-chat-detail .msg-bubble.mine .msg-meta {
  opacity: 0.82;
}

body.page-chat-detail .msg-bubble.mine .msg-read-state.read {
  color: rgba(255, 239, 191, 0.98);
}

  position: relative; /* Added position relative */
  border-width: 1px 0 0;
  border-radius: 0;
  padding: 10px;
  background: rgba(255,255,255,0.92);
}

body.page-chat-detail .chat-composer-note {
  order: 3;
  color: var(--chat-muted);
  padding: 0 4px 2px;
  font-size: 11px;
  font-weight: 750;
}

body.page-chat-detail .chat-attachment-preview {
  order: 2;
  padding: 0;
}

body.page-chat-detail .chat-input-bar {
  order: 1;
  width: 100%;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 18px;
  border: 1px solid rgba(44, 31, 78, 0.1);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(252,252,255,0.96));
  align-items: flex-end;
}

body.page-chat-detail .chat-msg-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 64px;
  max-height: 150px;
  padding: 13px 14px;
  border: 0;
  background: transparent;
  line-height: 1.8;
}

body.page-chat-detail .chat-attach-btn,
body.page-chat-detail .chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

body.page-chat-detail .chat-send-btn {
  background: linear-gradient(135deg, var(--chat-primary-strong), var(--chat-primary));
}

body.page-chat-detail .chat-preview-card {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid rgba(103, 58, 183, 0.12);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(253,249,255,0.96)),
    linear-gradient(135deg, rgba(103,58,183,0.05), rgba(241,165,89,0.08));
  box-shadow: 0 18px 36px rgba(26, 17, 51, 0.08);
}

body.page-chat-detail .chat-preview-media {
  min-height: 102px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(103,58,183,0.1), rgba(241,165,89,0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.page-chat-detail .chat-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.page-chat-detail .chat-preview-content {
  min-width: 0;
  display: grid;
  gap: 10px;
  align-content: center;
}

body.page-chat-detail .chat-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

body.page-chat-detail .chat-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.page-chat-detail .chat-preview-type,
body.page-chat-detail .chat-preview-size {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

body.page-chat-detail .chat-preview-type {
  color: var(--chat-primary-strong);
  background: rgba(103,58,183,0.1);
}

body.page-chat-detail .chat-preview-size {
  color: var(--chat-muted);
  background: rgba(15,23,42,0.05);
}

body.page-chat-detail .chat-preview-name {
  min-width: 0;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 800;
  color: var(--chat-ink);
  word-break: break-word;
}

body.page-chat-detail .chat-preview-subtitle {
  font-size: 12px;
  line-height: 1.7;
  color: var(--chat-muted);
  word-break: break-word;
}

body.page-chat-detail .chat-preview-remove {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(220, 38, 38, 0.12);
  border-radius: 14px;
  background: rgba(220, 38, 38, 0.06);
  color: #b91c1c;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

body.page-chat-detail .chat-preview-media.is-file .chat-preview-media-label,
body.page-chat-detail .chat-preview-media.is-audio .chat-preview-media-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 72px;
  padding: 0 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.8);
  color: var(--chat-primary-strong);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

body.page-chat-detail .chat-preview-audio-player {
  width: 100%;
  min-width: 0;
}

body.page-chat-detail .chat-sheet,
body.page-chat-detail .chat-report-dialog {
  border-radius: 22px;
  border-color: var(--chat-line);
  box-shadow: 0 28px 58px rgba(16, 12, 30, 0.22);
}

@media (max-width: 1023px) {
  body.page-chat-detail .chat-detail-page {
    padding: 10px 10px calc(var(--bottom-nav-height, 84px) + 12px);
  }

  body.page-chat-detail .chat-desktop-shell {
    display: flex;
    flex-direction: column;
  }

  body.page-chat-detail #bottom-nav {
    display: flex !important;
  }

  body.page-chat-detail .chat-desktop-sidebar,
  body.page-chat-detail .chat-desktop-main-frame {
    min-height: 0;
    border-radius: 22px;
  }

  body.page-chat-detail .chat-member-card {
    display: none;
  }

  body.page-chat-detail .chat-member-row-identity {
    display: flex;
  }

  body.page-chat-detail .chat-messages-shell {
    min-height: 54vh;
  }
}

@media (max-width: 640px) {
  body.page-chats .page-content {
    padding-top: calc(var(--navbar-height, 64px) + 8px);
  }

  body.page-chats .chats-layout {
    width: calc(100% - 16px);
  }

  body.page-chats .chats-page-top {
    min-height: 0;
    flex-direction: column;
    border-radius: 22px;
    padding: 18px;
  }

  body.page-chats .chats-page-title-wrap h1 {
    font-size: 2rem;
  }

  body.page-chats .chats-control-panel,
  body.page-chats .chats-list-panel {
    border-radius: 20px;
    padding: 12px;
  }

  body.page-chats .chat-thread-card {
    border-radius: 18px;
    padding: 12px;
  }

  body.page-chats .thread-open-hint {
    width: 100%;
    justify-content: center;
    margin-inline-start: 0;
  }

  body.page-chat-detail .chat-header-main {
    flex-direction: column;
    align-items: stretch;
  }

  body.page-chat-detail .chat-header-actions {
    align-self: stretch;
    justify-content: flex-end;
  }

  body.page-chat-detail .chat-messages {
    width: 100%;
    padding: 16px 14px 18px;
  }

  body.page-chat-detail .msg-bubble {
    min-width: 0;
    max-width: 84%;
    padding: 11px 13px 10px;
  }

  body.page-chat-detail .msg-row.is-system .msg-bubble {
    max-width: 92%;
  }

  body.page-chat-detail .msg-row.is-system::before,
  body.page-chat-detail .msg-row.is-system::after {
    width: calc(50% - 96px);
  }

  body.page-chat-detail .msg-bubble-menu-btn {
    opacity: 1;
  }

  body.page-chat-detail .chat-input-wrap {
    padding: 10px;
  }

  body.page-chat-detail .chat-preview-card {
    grid-template-columns: minmax(0, 1fr);
  }

  body.page-chat-detail .chat-preview-media {
    min-height: 154px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.page-chats *,
  body.page-chat-detail * {
    animation: none !important;
    transition: none !important;
  }
}
