.thraid-message-workspace {
  width: min(1480px, calc(100% - 2rem));
  margin: 1.5rem auto 0;
  border: 1px solid #2f3138;
  border-radius: 8px;
  background: #111216;
  color: #f8fafc;
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .28);
}
.thraid-message-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #2f3138;
  background: #0a0b0e;
}
.thraid-message-heading h2 { margin: 0; font-size: 1.25rem; line-height: 1.2; font-weight: 900; }
.thraid-message-heading p { margin: .25rem 0 0; color: #a1a1aa; font-size: .82rem; }
.thraid-message-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 250px;
  min-height: 650px;
  max-height: 78vh;
}
.thraid-message-sidebar,
.thraid-message-details {
  min-width: 0;
  background: #0d0e12;
  overflow: auto;
}
.thraid-message-sidebar { border-right: 1px solid #2f3138; }
.thraid-message-details { border-left: 1px solid #2f3138; padding: 1rem; }
.thraid-message-search { padding: 1rem; border-bottom: 1px solid #2f3138; }
.thraid-message-searchbox {
  display: flex;
  align-items: center;
  gap: .65rem;
  border: 1px solid #3f4149;
  border-radius: 8px;
  background: #18191e;
  padding: .75rem .85rem;
}
.thraid-message-searchbox input,
.thraid-message-composer textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: inherit;
  font: inherit;
}
.thraid-message-searchbox input::placeholder,
.thraid-message-composer textarea::placeholder { color: #71717a; }
.thraid-conversation-list,
.thraid-recipient-results { display: grid; gap: .35rem; padding: .65rem; }
.thraid-recipient-results:empty { display: none; }
.thraid-recipient-results:not(:empty) { border-bottom: 1px solid #2f3138; }
.thraid-conversation,
.thraid-recipient {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: .7rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .72rem;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.thraid-conversation:hover,
.thraid-recipient:hover,
.thraid-conversation.active { background: #1b1d23; border-color: #363945; }
.thraid-conversation.active { box-shadow: inset 3px 0 #f8bd06; }
.thraid-message-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #454854;
  background: #2563eb;
}
.thraid-message-person { min-width: 0; }
.thraid-message-person strong,
.thraid-message-person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thraid-message-person strong { font-size: .9rem; }
.thraid-message-person span { margin-top: .18rem; color: #9ca3af; font-size: .75rem; }
.thraid-message-unread {
  min-width: 1.5rem;
  height: 1.5rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: .7rem;
  font-weight: 900;
  padding: 0 .4rem;
}
.thraid-message-thread {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #14151a;
}
.thraid-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: .8rem 1rem;
  border-bottom: 1px solid #2f3138;
  background: #111216;
}
.thraid-thread-identity { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.thraid-thread-title { min-width: 0; }
.thraid-thread-title strong,
.thraid-thread-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thraid-thread-title span { color: #a1a1aa; font-size: .76rem; margin-top: .15rem; }
.thraid-admin-mark {
  display: inline-flex !important;
  align-items: center;
  gap: .3rem;
  width: max-content;
  margin-top: .3rem !important;
  color: #f8bd06 !important;
  font-weight: 800;
}
.thraid-thread-actions { display: flex; gap: .4rem; }
.thraid-icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #3f4149;
  border-radius: 8px;
  background: #1b1d23;
  color: inherit;
  cursor: pointer;
}
.thraid-icon-button:hover { border-color: #f8bd06; }
.thraid-message-back { display: none; }
.thraid-message-stream {
  min-height: 0;
  overflow: auto;
  padding: 1.15rem;
  scroll-behavior: smooth;
}
.thraid-message-day {
  width: max-content;
  margin: .5rem auto 1rem;
  border: 1px solid #343741;
  border-radius: 999px;
  padding: .35rem .65rem;
  color: #a1a1aa;
  font-size: .69rem;
  font-weight: 800;
}
.thraid-message-row { display: flex; margin: .55rem 0; }
.thraid-message-row.mine { justify-content: flex-end; }
.thraid-message-bubble {
  max-width: min(76%, 660px);
  border: 1px solid #343741;
  border-radius: 8px;
  border-top-left-radius: 2px;
  background: #202229;
  padding: .7rem .8rem;
  overflow: hidden;
}
.thraid-message-row.mine .thraid-message-bubble {
  border-color: #2563eb;
  border-top-left-radius: 8px;
  border-top-right-radius: 2px;
  background: #163d85;
}
.thraid-message-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; font-size: .9rem; }
.thraid-message-meta { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .4rem; color: #c4c7cf; font-size: .65rem; }
.thraid-message-delete { border: 0; background: transparent; color: inherit; cursor: pointer; opacity: .75; }
.thraid-message-media { display: block; max-width: 100%; max-height: 390px; margin-bottom: .55rem; border-radius: 6px; background: #050505; }
audio.thraid-message-media { width: min(360px, 100%); min-height: 42px; }
.thraid-message-file {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: inherit;
  text-decoration: none;
  margin-bottom: .45rem;
}
.thraid-message-empty { height: 100%; min-height: 330px; display: grid; place-items: center; padding: 2rem; text-align: center; color: #a1a1aa; }
.thraid-message-empty i { display: block; color: #f8bd06; font-size: 2.2rem; margin-bottom: .8rem; }
.thraid-message-composer {
  border-top: 1px solid #2f3138;
  background: #101115;
  padding: .8rem;
}
.thraid-attachment-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
  border: 1px solid #3f4149;
  border-radius: 8px;
  background: #1b1d23;
  padding: .55rem .7rem;
  font-size: .78rem;
}
.thraid-attachment-preview.show { display: flex; }
.thraid-composer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: .55rem; }
.thraid-composer-tools { display: flex; gap: .35rem; }
.thraid-message-composer textarea {
  min-height: 44px;
  max-height: 140px;
  border: 1px solid #3f4149;
  border-radius: 8px;
  background: #1b1d23;
  padding: .72rem .8rem;
}
.thraid-message-send {
  min-width: 48px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.thraid-message-send:disabled,
.thraid-icon-button:disabled { opacity: .5; cursor: wait; }
.thraid-recording { color: #fb7185 !important; border-color: #fb7185 !important; animation: thraidMessagePulse 1s infinite; }
@keyframes thraidMessagePulse { 50% { opacity: .55; } }
.thraid-message-detail-card {
  border-bottom: 1px solid #343741;
  padding: .9rem 0;
}
.thraid-message-detail-card:first-child { padding-top: 0; }
.thraid-message-detail-card h3 { margin: 0 0 .65rem; font-size: .86rem; }
.thraid-message-detail-card p { margin: 0; color: #a1a1aa; font-size: .76rem; line-height: 1.55; }
.thraid-message-detail-card button {
  width: 100%;
  margin-top: .45rem;
  border: 1px solid #3f4149;
  border-radius: 8px;
  background: #1b1d23;
  color: inherit;
  padding: .68rem;
  text-align: left;
  cursor: pointer;
  font-weight: 750;
}
.thraid-message-detail-card button:hover { border-color: #f8bd06; }
.thraid-message-detail-card button.danger:hover { border-color: #ef4444; color: #fca5a5; }
.thraid-message-status { padding: .55rem 1rem; color: #a1a1aa; font-size: .72rem; border-top: 1px solid #2f3138; }

html.light .thraid-message-workspace {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .1);
}
html.light .thraid-message-heading,
html.light .thraid-thread-head,
html.light .thraid-message-composer { background: #fff; border-color: #d6dce5; }
html.light .thraid-message-sidebar,
html.light .thraid-message-details { background: #f8fafc; }
html.light .thraid-message-sidebar { border-color: #d6dce5; }
html.light .thraid-message-details { border-color: #d6dce5; }
html.light .thraid-message-thread { background: #f1f5f9; }
html.light .thraid-message-search,
html.light .thraid-recipient-results:not(:empty) { border-color: #d6dce5; }
html.light .thraid-message-searchbox,
html.light .thraid-message-composer textarea,
html.light .thraid-icon-button,
html.light .thraid-message-detail-card button,
html.light .thraid-attachment-preview {
  border-color: #cbd5e1;
  background: #fff;
  color: #0f172a;
}
html.light .thraid-conversation:hover,
html.light .thraid-recipient:hover,
html.light .thraid-conversation.active { background: #e8eef8; border-color: #b8c4d6; }
html.light .thraid-message-bubble { border-color: #cbd5e1; background: #fff; color: #0f172a; }
html.light .thraid-message-row.mine .thraid-message-bubble { border-color: #2563eb; background: #dbeafe; }
html.light .thraid-message-meta { color: #475569; }
html.light .thraid-message-day { border-color: #cbd5e1; color: #64748b; background: #fff; }
html.light .thraid-message-detail-card { border-color: #d6dce5; }

@media (max-width: 1050px) {
  .thraid-message-layout { grid-template-columns: 285px minmax(0, 1fr); }
  .thraid-message-details { display: none; }
}
@media (max-width: 720px) {
  .thraid-message-workspace { width: 100%; margin-top: 0; border-left: 0; border-right: 0; border-radius: 0; }
  .thraid-message-heading { padding: .85rem 1rem; }
  .thraid-message-heading p { display: none; }
  .thraid-message-layout { display: block; min-height: calc(100dvh - 150px); max-height: none; }
  .thraid-message-sidebar { height: calc(100dvh - 150px); border-right: 0; }
  .thraid-message-thread { display: none; height: calc(100dvh - 150px); }
  .thraid-message-workspace.thread-open .thraid-message-sidebar { display: none; }
  .thraid-message-workspace.thread-open .thraid-message-thread { display: grid; }
  .thraid-message-back { display: inline-grid; }
  .thraid-message-bubble { max-width: 88%; }
  .thraid-composer-row { grid-template-columns: minmax(0, 1fr) auto; }
  .thraid-composer-tools { grid-column: 1 / -1; }
}
