.marketplace-product-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.marketplace-product-card > .item-card { flex: 1; }
.marketplace-product-card > .marketplace-actions { margin-top: .5rem; }
.marketplace-product-card > .marketplace-actions > .button { flex: 1 1 auto; text-align: center; }
.marketplace-notification-count[hidden] { display: none; }
.marketplace-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.marketplace-dialog label, .marketplace-activity label { display: grid; gap: .4rem; }
.marketplace-dialog textarea, .marketplace-activity textarea { min-height: 5rem; resize: vertical; }
.marketplace-messages { list-style: none; padding-inline-start: 0; margin-block: 1rem; }
.marketplace-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.own-marketplace-message { border-inline-start: 3px solid currentColor; }
.marketplace-notice { color: inherit; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.marketplace-notice small { margin-inline-start: auto; }
.marketplace-notice[data-unread] { border-inline-start: 3px solid currentColor; }
.marketplace-notification-count { font-variant-numeric: tabular-nums; }
@media (min-width: 861px) {
  .market-nav .marketplace-notification-count { display: none; }
}

.seller-chat-handle {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  min-height: 44px;
  text-align: start;
  cursor: pointer;
}
.account-marketplace-handle { margin: .55rem 0 0; font-weight: 600; }
.marketplace-chat-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(100%, 420px);
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: var(--white, #fff);
  color: var(--ink, #182132);
}
.marketplace-chat-drawer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.marketplace-chat-drawer::backdrop { background: #121c3490; }
.marketplace-chat-drawer > header,
.marketplace-chat-drawer > footer { padding: .85rem 1.15rem; }
.marketplace-chat-drawer > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding-top: max(.85rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line, #ddd);
}
.marketplace-chat-drawer h2 { margin: .2rem 0 0; }
.marketplace-chat-drawer > footer { border-top: 1px solid var(--line, #ddd); padding-bottom: max(.85rem, env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: no-preference) {
  .marketplace-chat-drawer[open] { animation: chat-slide-in 200ms ease-out; }
  @keyframes chat-slide-in { from { transform: translateX(100%); } }
}
[data-chat-panel] {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.chat-context { padding: .7rem 1rem; margin: 0; background: #f4f6fa; overflow-wrap: anywhere; }
.chat-context span { font-size: .85em; margin-inline-start: .4rem; }
.chat-history { overflow: auto; overscroll-behavior: contain; padding: .8rem 1rem; }
.chat-older { display: block; margin: 0 auto .55rem; min-height: 44px; }
.chat-older[hidden] { display: none; }
.chat-messages { list-style: none; display: flex; flex-direction: column; gap: .6rem; margin: 0; padding: 0; }
.chat-messages .chat-bubble {
  align-self: flex-start;
  max-width: 85%;
  border-radius: 1rem 1rem 1rem .3rem;
  background: #edf0f5;
  color: #172132;
  padding: .5rem .75rem;
  overflow-wrap: anywhere;
}
.chat-messages .chat-own { align-self: flex-end; border-radius: 1rem 1rem .3rem 1rem; background: #deebf9; }
.chat-messages p { margin: 0; white-space: pre-wrap; }
.chat-messages time, .inbox-thread time { display: block; margin-top: .2rem; color: #465264; font-size: .75rem; }
.chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .45rem .65rem; padding: .65rem 1rem; border-top: 1px solid var(--line, #ddd); }
.chat-composer label { display: grid; min-width: 0; }
.chat-composer textarea { width: 100%; min-height: 48px; max-height: 8rem; resize: vertical; font-size: 16px; }
.chat-composer .button { grid-column: 2; min-height: 44px; }
.chat-composer [data-error] { grid-column: 1 / -1; margin: 0; }
.messages-inbox { display: grid; grid-template-columns: minmax(190px, .65fr) minmax(0, 1.35fr); gap: 1rem; }
.inbox-sidebar, .inbox-conversation { min-width: 0; }
.inbox-threads { display: grid; gap: .35rem; max-height: 65vh; overflow: auto; margin-top: .65rem; }
.inbox-more { min-height: 44px; }
.inbox-more[hidden] { display: none; }
.inbox-thread { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .4rem; color: inherit; text-decoration: none; padding: .65rem .75rem; border: 1px solid var(--line, #ddd); border-radius: .55rem; }
.inbox-thread:hover, .inbox-thread[aria-current] { background: #edf2fb; }
.inbox-thread > span:not(.chat-unread), .inbox-thread time { grid-column: 1 / -1; }
.inbox-thread > span:not(.chat-unread) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread { align-self: start; border-radius: 1rem; padding: .1rem .45rem; background: #243d71; color: #fff; font-size: .8rem; }
.inbox-conversation [data-chat-panel] { grid-template-rows: auto minmax(8rem, 52vh) auto; }
.inbox-conversation > .button { display: none; }
@media (max-width: 680px) {
  .messages-inbox { grid-template-columns: minmax(0, 1fr); }
  .messages-inbox.has-conversation .inbox-sidebar, .messages-inbox:not(.has-conversation) .inbox-conversation { display: none; }
  .inbox-conversation > .button { display: inline-flex; }
}

#marketplace-chat-launcher {
  position: fixed;
  z-index: 40;
  inset-inline-end: 0;
  inset-block-end: max(24vh, calc(env(safe-area-inset-bottom) + 5.5rem));
  display: grid;
  place-items: center;
  width: 56px;
  height: 54px;
  padding: 5px 8px 5px 5px;
  border: 1px solid #d5deea;
  border-inline-end: 0;
  border-radius: 28px 0 0 28px;
  background: #fff;
  color: #243d71;
  box-shadow: 0 4px 16px #17213228;
  cursor: pointer;
}
#marketplace-chat-launcher[hidden] { display: none; }
#marketplace-chat-launcher:focus-visible { outline-offset: -3px; }
#marketplace-chat-launcher .account-avatar { width: 40px; height: 40px; }
#marketplace-chat-launcher svg {
  position: absolute;
  inset-inline-end: 5px;
  inset-block-end: 4px;
  width: 18px;
  height: 18px;
  padding: 2px;
  border-radius: 50%;
  background: #fff;
}
.chat-drawer-body { display: grid; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.chat-start { padding: 1rem 1.15rem; overflow: auto; }
.chat-start input { width: 100%; font-size: 16px; }
.chat-start form { display: grid; gap: .65rem; }
.chat-start form > .button { justify-self: start; }
.chat-start .inbox-thread { background: #fff; text-align: start; cursor: pointer; font: inherit; }
.chat-start .inbox-thread:hover { background: #edf2fb; }
.marketplace-chat-drawer > footer { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.marketplace-chat-drawer > footer > a { margin-inline-start: auto; }

.marketplace-chat-drawer {
  --chat-ink: #182744;
  --chat-border: #dce4ef;
  inset-block-start: var(--chat-viewport-top, 0px);
  height: var(--chat-viewport-height, 100dvh);
  width: min(100%, 480px);
  color: var(--chat-ink);
  box-shadow: -12px 0 48px #14243828;
}
.marketplace-chat-drawer > header { background: #f7faff; }
.chat-title-lockup, .chat-inbox-header { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.chat-inbox-header { justify-content: space-between; margin-bottom: 1rem; }
.chat-inbox-header h2 { margin: 0; }
.chat-title-lockup h2 { margin: 0; font-size: clamp(1.05rem, 4vw, 1.35rem); overflow-wrap: anywhere; }
.chat-title-lockup > span {
  display: grid; place-items: center; flex: 0 0 40px; height: 40px;
  border-radius: 50%; background: #dfeaff; color: #28436e; font-weight: 700;
}
.chat-transcript { display: grid; grid-template-rows: minmax(0, 1fr); position: relative; min-height: 0; background: #f8faff; }
.chat-history { min-height: 0; padding-block: 1rem; }
.chat-day { align-self: center; color: #45556e; font-size: .75rem; font-weight: 650; padding: .25rem .65rem; }
.chat-messages .chat-bubble { background: #fff; border: 1px solid #dbe3ef; border-radius: 14px 14px 14px 5px; }
.chat-messages .chat-own { background: #e5eefc; border-color: #d7e3f7; border-radius: 14px 14px 5px 14px; }
.chat-bubble blockquote {
  display: grid; gap: .2rem; margin: 0 0 .45rem; padding: .35rem .55rem;
  border-inline-start: 3px solid #5f79a4; background: #edf2fa; font-size: .8rem; border-radius: .2rem;
}
.chat-bubble blockquote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-bubble-meta { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.chat-reply { appearance: none; background: transparent; border: 0; color: #304f7e; padding: 0 .1rem; min-height: 32px; font: inherit; font-size: .8rem; cursor: pointer; }
.chat-reply:hover { text-decoration: underline; }
.chat-latest {
  position: absolute; inset-inline-end: 1rem; inset-block-end: .6rem;
  z-index: 1; border-radius: 1.4rem; background: white; box-shadow: 0 2px 12px #1e3b5c26;
}
.chat-latest[hidden], .chat-reply-preview[hidden], [data-drawer-new][hidden] { display: none; }
.chat-reply-preview {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; border-inline-start: 3px solid #5f79a4; background: #edf3fc; padding: .35rem .55rem; font-size: .86rem;
}
.chat-reply-preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-composer { padding-block: .65rem; background: #fff; }
.chat-composer textarea { min-height: 46px; max-height: 112px; resize: none; border-radius: 14px; }
.chat-composer-meta {
  display: flex; grid-column: 1 / -1; justify-content: space-between; color: #465264; font-size: .75rem;
}
.chat-composer-meta:has([role="status"]:empty):has([data-chat-limit][hidden]) { display: none; }
.chat-composer [data-error] { order: 1; }
.inbox-conversation [data-chat-panel] { border: 1px solid #dce4ef; border-radius: 14px; overflow: hidden; }
.chat-inbox-filters { display: flex; gap: .35rem; margin-block: .55rem; }
.chat-inbox-filters button {
  appearance: none; border: 1px solid #dce4ef; border-radius: 999px; background: white; color: #23395d;
  min-height: 38px; padding-inline: .85rem; font: inherit; cursor: pointer;
}
.chat-inbox-filters button[aria-pressed="true"] { background: #243d71; border-color: #243d71; color: white; }
@media (pointer: coarse) {
  .chat-reply, .chat-inbox-filters button { min-height: 44px; }
}

/* Shared controls for the chat drawer and account inbox. */
.marketplace-chat-drawer {
  --chat-surface: #f4f7fc;
  --chat-ink: #13213b;
  --chat-accent: #244785;
  color: var(--chat-ink);
  width: min(100%, 488px);
}
.marketplace-chat-drawer > header { background: white; padding-inline: 1rem; }
.marketplace-chat-drawer > footer { padding-inline: 1rem; box-shadow: 0 -1px 8px #1a335009; }
.chat-title-lockup > span:first-child { background: #e7edfc; color: #264983; }
.chat-title-lockup h2 { font-weight: 730; letter-spacing: -.025em; }
.chat-stream-marker {
  display: none; flex-wrap: nowrap; gap: .3rem; align-items: center; color: #2b5043; font-size: .72rem; font-weight: 650;
}
.chat-stream-marker::before { content: ''; width: 6px; height: 6px; border-radius: 100%; background: #258360; }
.marketplace-chat-drawer:has([data-chat-live]) .chat-stream-marker { display: inline-flex; }
.chat-transcript { background: var(--chat-surface, #f4f7fc); }
.chat-history { padding-inline: .9rem; }
.chat-context { padding: .6rem .95rem; background: white; border-bottom: 1px solid #e6ebf4; color: #52627a; font-size: .875rem; }
.chat-messages { gap: .75rem; }
.chat-messages .chat-bubble {
  padding: .6rem .75rem .3rem; border: 0; border-radius: 18px 18px 18px 5px;
  box-shadow: 0 1px 3px #172e5511; max-width: min(84%, 34rem);
}
.chat-messages .chat-own {
  color: white; background: var(--chat-accent, #244785); border-radius: 18px 18px 5px 18px;
}
.chat-bubble p { line-height: 1.45; }
.chat-messages .chat-own :is(time, .chat-reply) { color: #e5edff; }
.chat-messages .chat-own blockquote { background: #ffffff18; border-inline-start-color: #b3cdfc; }
.chat-bubble-meta { gap: .35rem; }
.chat-bubble-meta time { white-space: nowrap; }
.chat-icon-button, .chat-action, .chat-latest {
  appearance: none; border: 0; font: inherit; font-weight: 620; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  color: #24477f; background: #ebf1fb; text-decoration: none;
}
.chat-action, .chat-latest { border-radius: 12px; min-height: 44px; padding-inline: .75rem; font-size: .875rem; }
.chat-icon-button { width: 44px; height: 44px; padding: 0; border-radius: 14px; flex: none; }
.chat-action svg, .chat-icon-button svg, .chat-latest svg { width: 19px; height: 19px; flex: none; }
.chat-action:hover, .chat-icon-button:hover, .chat-latest:hover { background: #dce9fc; }
.chat-icon-button:focus-visible, .chat-action:focus-visible, .chat-latest:focus-visible { outline: 2px solid #537dbb; outline-offset: 2px; }
.chat-icon-button:disabled { cursor: wait; opacity: .55; }
.chat-reply { width: 34px; height: 30px; min-height: 30px; border-radius: 9px; background: transparent; }
.chat-reply svg { width: 16px; height: 16px; }
.chat-own .chat-reply:hover { background: #ffffff26; }
.chat-latest { background: white; border-radius: 999px; }
.chat-composer { grid-template-columns: minmax(0, 1fr) 46px; gap: .4rem .55rem; padding: .65rem .85rem; }
.chat-composer textarea { padding: .68rem .85rem; background: #f7f9fd; border: 1px solid #e0e7f1; border-radius: 17px; }
.chat-composer textarea:focus { border-color: #88a6d6; }
.chat-composer .chat-send, .chat-start-submit { color: #fff; background: #244785; }
.chat-composer .chat-send { grid-column: 2; width: 46px; height: 46px; }
.chat-composer .chat-send:hover, .chat-start-submit:hover { background: #19376d; }
.chat-inbox-back { display: none; }
.chat-inbox-filters button { border: 0; background: #eef2f8; }
.inbox-thread { border: 1px solid transparent; background: #f7f9fe; border-radius: 13px; }
.inbox-thread[aria-current] { border-color: #c8dbf8; }
.chat-start .inbox-thread { background: #f7f9fe; }
@media (max-width: 680px) {
  .chat-inbox-back { display: inline-flex; }
  .chat-inbox-header .chat-action { padding-inline: .55rem; }
}
@media (pointer: coarse) {
  .chat-reply { width: 44px; height: 44px; }
}

.marketplace-chat-drawer {
  --chat-surface: #121b2b;
  --chat-ink: #eff4ff;
  --chat-accent: #b5eb68;
  --chat-control: #24334b;
  --chat-outline: #394b65;
  background: #101827;
  color-scheme: dark;
}
.marketplace-chat-drawer > :is(header, footer) { background: #101827; border-color: #35455e; }
.marketplace-chat-drawer .chat-title-lockup > span:first-child {
  color: #172317; background: #b5eb68; border-radius: 14px 14px 5px 14px;
}
.marketplace-chat-drawer :is(.note, .chat-context, .chat-composer-meta, .chat-day) { color: #b3c2da; }
.marketplace-chat-drawer .chat-stream-marker { color: #b5eb68; }
.marketplace-chat-drawer .chat-stream-marker::before { background: currentColor; }
.marketplace-chat-drawer :is(.chat-context, .chat-composer) { background: #101827; border-color: #35455e; }
.marketplace-chat-drawer :is(.chat-icon-button, .chat-action, .chat-latest) { color: #f0f5ff; background: var(--chat-control); }
.marketplace-chat-drawer :is(.chat-icon-button, .chat-action, .chat-latest):hover { background: #304565; }
.marketplace-chat-drawer .chat-messages .chat-bubble { background: #26364d; color: #f0f5ff; }
.marketplace-chat-drawer .chat-messages .chat-own { background: #b5eb68; color: #142014; }
.marketplace-chat-drawer .chat-bubble time { color: #c7d6ee; }
.marketplace-chat-drawer .chat-bubble .chat-reply { background: #374b67; }
.marketplace-chat-drawer .chat-own :is(time, .chat-reply) { color: #203320; }
.marketplace-chat-drawer .chat-own .chat-reply { background: #17320d1a; }
.marketplace-chat-drawer .chat-bubble blockquote { background: #ffffff18; border-inline-start-color: #8fa9cc; }
.marketplace-chat-drawer .chat-own blockquote { background: #203b171c; border-inline-start-color: #426f25; }
.marketplace-chat-drawer .chat-reply-preview { background: #24334b; border-inline-start-color: #b5eb68; }
.chat-composer { grid-template-columns: minmax(0, 1fr) auto; }
.chat-composer .chat-send { width: auto; padding-inline: .8rem; }
.marketplace-chat-drawer :is(.chat-send, .chat-start-submit) { color: #152316; background: #b5eb68; font-weight: 750; }
.marketplace-chat-drawer :is(.chat-send, .chat-start-submit):hover { color: #152316; background: #cdf995; }
.marketplace-chat-drawer :is(.chat-composer textarea, .chat-first-message textarea) {
  color: #f0f5ff; background: #19253a; border: 1px solid var(--chat-outline);
}
.marketplace-chat-drawer :is(input, textarea)::placeholder { color: #a5b5ce; }
.marketplace-chat-drawer :is(input, textarea):focus-visible { outline: 2px solid #b5eb68; outline-offset: 1px; }
.marketplace-chat-drawer [role="alert"] { color: #ffb9b9; }
.chat-start { padding: .9rem 1rem; }
.chat-start .chat-recipient-form {
  margin: 0; padding: .75rem; border: 1px solid #496142; border-radius: 16px;
  background: #18273b; box-shadow: 0 14px 30px #080d1830;
}
.chat-recipient-form .chat-recipient-field {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; padding-inline-start: .65rem;
  gap: .55rem; font-weight: 700; color: #c5d3e8; border: 1px solid var(--chat-outline); border-radius: 10px;
}
.chat-recipient-field input {
  padding: .45rem .55rem; min-width: 0; min-height: 44px; color: #f0f5ff;
  background: #172336; border: 0; border-radius: 0 9px 9px 0;
}
.chat-first-message textarea {
  display: block; width: 100%; min-height: 68px; max-height: 120px; padding: .6rem .65rem;
  resize: vertical; border-radius: 11px; font: inherit; font-size: 16px;
}
.chat-start-actions { display: flex; justify-content: space-between; align-items: center; gap: .45rem; }
.chat-start-actions [role="status"] { color: #b5eb68; font-size: .8rem; }
.chat-start-actions .chat-start-submit { margin-inline-start: auto; }
.chat-start-actions .chat-start-submit:disabled { opacity: .55; }
.chat-recent h3 { margin: 1rem 0 .45rem; color: #dde8f9; font-size: .92rem; }
.marketplace-chat-drawer .chat-recent-thread {
  grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: .55rem;
  min-height: 52px; color: #f0f5ff; background: #19263a; border-color: #293951;
}
.marketplace-chat-drawer .chat-recent-thread:hover { background: #233651; }
.chat-recent-thread > :is(.chat-thread-avatar, .chat-thread-copy):not(.chat-unread) { grid-column: auto; }
.chat-thread-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #cdecb6; background: #35463a; }
.chat-thread-copy { display: grid; gap: .1rem; min-width: 0; }
.chat-thread-copy > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b3c2da; font-size: .8rem; }
.chat-recent-thread .chat-unread { color: #172317; background: #b5eb68; }
.marketplace-chat-drawer :is(.chat-context .text-link, .chat-older) { color: #cde3ff; }
