.peps-chat-panel, .peps-inbox-page {
  --chat-bg: #161422;
  --chat-card: #211e32;
  --chat-text: #f7f5ff;
  --chat-muted: #cbc6dc;
  --chat-line: #514862;
  --chat-accent: #81eff8;
  color: var(--chat-text);
  background: var(--chat-bg);
  font: 15px/1.5 system-ui, sans-serif;
  color-scheme: dark;
}
.peps-chat-panel *, .peps-inbox-page * { box-sizing: border-box; }
.peps-chat-panel [hidden], .peps-inbox-page [hidden], .peps-chat-panel[hidden] { display: none !important; }
.peps-chat-panel button, .peps-inbox-page button, .peps-chat-panel textarea,
.peps-inbox-page textarea, .peps-inbox-page input { font: inherit; }
.peps-chat-panel button, .peps-inbox-page button {
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--chat-text);
  background: var(--chat-card);
  cursor: pointer;
}
.peps-chat-panel button:disabled, .peps-inbox-page button:disabled { opacity: .55; cursor: default; }
.peps-chat-panel :focus-visible, .peps-inbox-page :focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 3px; }
.peps-chat-panel {
  position: fixed;
  z-index: 1300;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: min(390px, calc(100% - 32px));
  max-height: calc(100dvh - 105px - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--chat-line);
  border-radius: 16px;
  box-shadow: 0 14px 50px #0d081b73;
  overflow: auto;
}
.peps-chat-launch.chat-launch { bottom: calc(16px + env(safe-area-inset-bottom)); }
.peps-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--chat-card);
  border-bottom: 1px solid var(--chat-line);
}
.peps-chat-header button { min-width: 40px; min-height: 40px; font-size: 22px; line-height: 1; }
.peps-chat-body { display: grid; min-height: 0; gap: 10px; padding: 16px; }
.peps-chat-intro, .peps-chat-status { margin: 0; font-size: 13px; color: var(--chat-muted); }
.peps-chat-status:empty, .peps-chat-panel .peps-chat-log:empty { display: none; }
.peps-chat-log { display: flex; flex-direction: column; gap: 10px; overflow: auto; max-height: min(260px, 32dvh); padding: 4px; }
.peps-chat-message {
  align-self: flex-start;
  max-width: 91%;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--chat-card);
  color: var(--chat-text);
  overflow-wrap: anywhere;
}
.peps-chat-message.is-mine { align-self: flex-end; background: #263944; }
.peps-chat-message small { color: var(--chat-muted); }
.peps-chat-message p { margin: 3px 0 0; white-space: pre-wrap; }
.peps-chat-compose { display: grid; gap: 6px; }
.peps-chat-compose label, .peps-inbox-login label { font-weight: 650; }
.peps-chat-compose textarea, .peps-inbox-login input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: #100f19;
  color: var(--chat-text);
  font-size: 16px;
}
.peps-chat-compose textarea { resize: vertical; }
.peps-chat-compose button, .peps-inbox-login button {
  justify-self: end;
  min-height: 42px;
  border-color: transparent;
  background: var(--chat-accent);
  color: #111622;
  font-weight: 700;
}
.peps-chat-panel .peps-chat-contact { color: var(--chat-accent); font-size: 13px; text-decoration: underline; }
.peps-inbox-page { margin: 0; min-height: 100dvh; }
.peps-inbox-header, .peps-inbox-page main { width: min(1120px, calc(100% - 32px)); margin: auto; }
.peps-inbox-header {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--chat-line);
  border-radius: 14px;
  background: var(--chat-bg);
  box-shadow: 0 8px 24px #07060c55, inset 0 1px 0 #e7c9ff16;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  @media not (prefers-reduced-transparency: reduce) {
    .peps-inbox-header {
      background: rgb(22 20 34 / .78);
      -webkit-backdrop-filter: blur(20px) saturate(145%);
      backdrop-filter: blur(20px) saturate(145%);
    }
  }
}
.peps-inbox-header a { display: inline-flex; align-items: center; gap: 7px; color: inherit; text-decoration: none; font-weight: 750; }
.peps-inbox-page h1 { font-size: clamp(26px, 6vw, 44px); margin: 24px 0 12px; letter-spacing: -.04em; }
.peps-inbox-page h2 { font-size: 17px; margin: 0; }
.peps-inbox-login { display: grid; gap: 14px; max-width: 430px; padding: 18px 0; }
.peps-inbox-login label { display: grid; gap: 6px; }
.peps-inbox-page .peps-chat-status:not(:empty) { margin-bottom: 12px; }
.peps-inbox { display: grid; grid-template-columns: minmax(225px, 1fr) minmax(0, 2fr); border: 1px solid var(--chat-line); border-radius: 14px; min-height: 450px; margin-bottom: 20px; }
.peps-inbox-list, .peps-inbox-detail { min-width: 0; padding: 15px; }
.peps-inbox-list { border-right: 1px solid var(--chat-line); }
#threads { display: grid; gap: 8px; margin-top: 12px; max-height: 60dvh; overflow: auto; }
#threads button { display: grid; text-align: left; gap: 3px; }
#threads button[aria-pressed="true"] { border-color: var(--chat-accent); }
#threads small { color: var(--chat-muted); }
#threads span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peps-inbox-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.peps-inbox-toolbar #back { display: none; }
.peps-inbox-detail .peps-chat-log { max-height: 52dvh; margin: 12px 0; }
@media (max-width: 650px) {
  .peps-inbox { grid-template-columns: 1fr; }
  .peps-inbox-list { border: 0; }
  .peps-inbox.has-thread .peps-inbox-list, .peps-inbox:not(.has-thread) .peps-inbox-detail { display: none; }
  .peps-inbox-toolbar #back { display: inline-block; }
}
