.inbox-view { min-height:0; padding-bottom:20px; }
body:has(.inbox-view) > footer { display:none; }
.inbox-layout {
  display:grid;
  grid-template-columns:300px minmax(0, 1fr);
  height:calc(100dvh - 292px);
  min-height:360px;
  max-height:760px;
  margin-top:24px;
  border:1px solid var(--sp-border);
  border-radius:5px;
  overflow:hidden;
}
.conversation-list { overflow-y:auto; border-right:1px solid var(--sp-border); }
.conversation-item {
  display:flex;
  align-items:flex-start;
  gap:12px;
  width:100%;
  min-height:105px;
  padding:20px 16px;
  text-align:left;
  border:0;
  border-bottom:1px solid var(--sp-border-soft);
  background:#fff;
}
.conversation-item:hover { background:var(--sp-surface-soft); }
.conversation-item.selected { background:var(--sp-green-soft); }
.conversation-avatar {
  display:flex;
  align-items:center;
  justify-content:center;
  flex:0 0 38px;
  width:38px;
  height:38px;
  border-radius:50%;
  background:var(--sp-bg);
  color:var(--sp-muted);
  font-size:.8125rem;
  overflow:hidden;
}
.conversation-avatar img { width:100%; height:100%; object-fit:cover; }
.conversation-preview { display:flex; flex:1; flex-direction:column; min-width:0; gap:4px; }
.conversation-name { display:flex; align-items:center; gap:8px; font-size:.875rem; font-weight:600; }
.conversation-topic,.conversation-snippet { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.75rem; color:var(--sp-muted); }
.conversation-snippet { color:var(--sp-text-body); }
.conversation-item > time { flex-shrink:0; font-size:.6875rem; color:var(--sp-muted); }
.conversation-thread { display:flex; flex-direction:column; min-width:0; min-height:0; }
.conversation-header { display:flex; align-items:center; gap:16px; padding:19px 24px; border-bottom:1px solid var(--sp-border); }
.conversation-heading { min-width:0; }
.conversation-heading h2 { font-size:1rem; }
.conversation-heading > p { margin-top:3px; color:var(--sp-muted); font-size:.8125rem; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.conversation-back { display:none; }
.conversation-back svg { display:block; width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.conversation-privacy { display:none; }
.message-send svg { display:none; }
.message-list { display:flex; flex:1; flex-direction:column; min-height:0; gap:12px; padding:20px 24px; overflow-y:auto; overscroll-behavior:contain; overflow-anchor:none; }
.message-day { margin:6px 0 9px; text-align:center; font-size:.6875rem; color:var(--sp-muted); }
.message { align-self:flex-start; max-width:82%; padding:10px 13px 7px; border-radius:5px; background:var(--sp-bg); }
.message.mine { align-self:flex-end; background:var(--sp-green-soft); }
.message p { font-size:.875rem; line-height:1.65; white-space:pre-wrap; overflow-wrap:anywhere; }
.message time { display:block; margin-top:3px; text-align:right; font-size:.625rem; color:var(--sp-muted); }
.message-composer { padding:15px 20px; border-top:1px solid var(--sp-border); background:#fff; }
.composer-row { display:flex; align-items:flex-end; gap:10px; }
.composer-row textarea { flex:1; min-height:44px; max-height:120px; height:44px; padding:10px 12px; font-size:1rem; line-height:1.4; resize:vertical; }
.composer-row .button { flex-shrink:0; }
.message-attach { display:flex; align-items:center; justify-content:center; flex:0 0 44px; width:44px; height:44px; padding:10px; border:0; border-radius:50%; background:transparent; color:var(--sp-muted); }
.message-attach svg,.message-attachment > svg { width:22px; height:22px; flex-shrink:0; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.message-attach:active { background:var(--sp-green-soft); }
.attachment-drafts { display:flex; flex-direction:column; gap:6px; max-height:168px; overflow-y:auto; padding-bottom:10px; }
.attachment-draft { display:flex; align-items:center; gap:10px; padding:2px 8px 2px 12px; border:1px solid var(--sp-border); border-radius:6px; }
.attachment-copy { display:flex; flex:1; min-width:0; flex-direction:column; gap:2px; }
.attachment-copy strong { font-size:.875rem; font-weight:550; overflow-wrap:anywhere; }
.attachment-draft strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.attachment-copy small { color:var(--sp-muted); font-size:.75rem; }
.attachment-draft button { flex:0 0 44px; width:44px; height:44px; padding:0; border:0; border-radius:4px; background:transparent; color:var(--sp-muted); font-size:1.4rem; }
.attachment-draft button:active { background:var(--sp-green-soft); }
.message-attachment { display:flex; align-items:center; gap:10px; min-height:48px; padding:6px 0; color:var(--sp-text); text-decoration:none; }
.message-attachment + .message-attachment { border-top:1px solid var(--sp-border); }
.message-attachment:hover strong { text-decoration:underline; }
.attachment-privacy,.attachment-status { font-size:.75rem; color:var(--sp-muted); line-height:1.5; padding-bottom:8px; }
.attachment-status:empty { display:none; }
.message-privacy { font-size:.75rem; color:var(--sp-muted); margin-bottom:10px; }
.inbox-empty { display:flex; flex:1; flex-direction:column; align-items:center; justify-content:center; padding:32px 24px; color:var(--sp-muted); text-align:center; }
.inbox-empty h2 { font-size:1rem; color:var(--sp-text); margin-bottom:8px; }
.inbox-empty p { font-size:.875rem; line-height:1.7; }
.conversation-list > .inbox-empty { min-height:240px; }
.no-conversations { grid-template-columns:1fr; }
.no-conversations .conversation-list { border:0; }
.no-conversations .conversation-thread { display:none; }
.inbox-loading { padding:24px; font-size:.875rem; color:var(--sp-muted); }
.inbox-status { font-size:.8125rem; color:var(--sp-muted); padding-top:10px; }
.inbox-status:empty { display:none; }
.earlier-messages { align-self:center; font-size:.75rem; }
@media (max-width:850px) {
  .inbox-layout { grid-template-columns:260px minmax(0, 1fr); height:calc(100dvh - 272px); }
  .inbox-layout.no-conversations { grid-template-columns:1fr; }
}
@media (max-width:680px) {
  .inbox-view { padding:20px 20px 0; }
  .inbox-view .page-heading { margin-bottom:14px; }
  .inbox-layout { display:block; height:calc(100dvh - 216px - env(safe-area-inset-bottom, 0px)); min-height:240px; max-height:none; margin:0 -20px; border:0; border-radius:0; border-top:1px solid var(--sp-border); }
  .conversation-list { height:100%; border:0; }
  .conversation-item { padding:19px 20px; }
  .conversation-item.selected { background:#fff; }
  .conversation-thread { display:none; height:100%; }
  .thread-open .conversation-list { display:none; }
  .thread-open .conversation-thread { display:flex; }
  .conversation-back { display:block; font-size:.8125rem; }
  .conversation-header { padding:13px 20px; gap:18px; }
  .conversation-heading h2 { font-size:.9375rem; }
  .conversation-heading > p { font-size:.75rem; }
  .message-list { padding:16px 20px; }
  .message-composer { padding:12px 16px; }
  .message { max-width:88%; }
  .message p { font-size:.9375rem; }
  .message time { font-size:.6875rem; }

  /* Only an open conversation takes over the mobile viewport. */
  body:has(.inbox-view .thread-open) {
    padding-bottom:0;
    overflow:hidden;
  }
  body:has(.inbox-view .thread-open) > .site-header,
  .inbox-view:has(.thread-open) > .page-heading,
  .inbox-view:has(.thread-open) > .market-navigation {
    display:none;
  }
  main.inbox-view:has(.thread-open) {
    position:fixed;
    top:var(--chat-top, 0px);
    left:0;
    right:0;
    height:var(--chat-height, 100dvh);
    max-width:none;
    margin:0;
    padding:0;
    z-index:30;
    background:var(--sp-surface);
  }
  .thread-open { height:100%; }
  .thread-open .inbox-layout {
    height:100%;
    min-height:0;
    margin:0;
    border:0;
  }
  .thread-open .conversation-header {
    flex-shrink:0;
    min-height:64px;
    gap:7px;
    padding:calc(10px + env(safe-area-inset-top, 0px)) 16px 10px 8px;
  }
  .thread-open .conversation-back {
    display:flex;
    align-items:center;
    justify-content:center;
    flex:0 0 44px;
    width:44px;
    height:44px;
    padding:0;
    color:var(--sp-text);
    text-decoration:none;
  }
  .thread-open .conversation-heading h2 { font-size:1rem; }
  .thread-open .conversation-heading > p { display:none; }
  .thread-open .conversation-privacy { display:block; color:var(--sp-muted); font-size:.75rem; margin-top:2px; }
  .thread-open .message-list { gap:9px; padding:16px; }
  .thread-open .message { max-width:84%; border-radius:15px; padding:9px 13px 6px; }
  .thread-open .message p { font-size:1rem; line-height:1.5; }
  .thread-open .message time { font-size:.625rem; }
  .thread-open .message-composer {
    flex-shrink:0;
    padding:10px 8px calc(10px + env(safe-area-inset-bottom, 0px)) 16px;
    border:0;
  }
  .thread-open .message-privacy { display:none; }
  .thread-open .composer-row { gap:4px; }
  .thread-open .composer-row textarea {
    border:0;
    border-radius:22px;
    background:var(--sp-bg);
    padding:11px 15px;
    min-height:44px;
    resize:none;
  }
  .thread-open .message-send {
    width:44px;
    height:44px;
    padding:10px;
    border:0;
    border-radius:50%;
    background:transparent;
    color:var(--sp-green);
  }
  .thread-open .message-send:hover { background:var(--sp-green-soft); }
  .thread-open .message-send span { display:none; }
  .thread-open .message-send svg {
    display:block;
    width:24px;
    height:24px;
    fill:none;
    stroke:currentColor;
    stroke-width:1.6;
    stroke-linecap:round;
    stroke-linejoin:round;
  }
  .thread-open .inbox-status:not(:empty) {
    position:absolute;
    bottom:calc(72px + env(safe-area-inset-bottom, 0px));
    left:16px;
    right:16px;
    padding:8px 12px;
    background:var(--sp-surface);
    border:1px solid var(--sp-border);
    border-radius:5px;
  }
}
