/* 破局助手 · 极简暖米色杂志风悬浮客服样式（无第三方依赖） */
body {
  padding-bottom: 88px;
}

.pj-chat-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--line, #d6cdc2);
  background: var(--paper, #fffdf9);
  color: var(--ink, #1a1714);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(26, 23, 20, 0.12);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.pj-chat-fab:hover,
.pj-chat-fab:focus-visible {
  border-color: var(--accent, #2c5580);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(26, 23, 20, 0.16);
}

html[data-theme="dark"] .pj-chat-fab {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.pj-chat-fab[hidden] {
  display: none;
}

.pj-chat-fish {
  width: 24px;
  height: 12px;
  flex: 0 0 auto;
  color: var(--accent, #2c5580);
}

.pj-chat-fab .pj-chat-fish {
  width: 29px;
  height: 15px;
}

.pj-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(26, 23, 20, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

html[data-theme="dark"] .pj-chat-backdrop {
  background: rgba(0, 0, 0, 0.52);
}

.pj-chat-backdrop[hidden] {
  display: none;
}

.pj-chat-drawer {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 70;
  width: min(392px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line, #d6cdc2);
  background: var(--paper, #fffdf9);
  color: var(--ink, #1a1714);
  font-family: var(--sans, system-ui, sans-serif);
  box-shadow: 0 18px 46px rgba(26, 23, 20, 0.18);
}

html[data-theme="dark"] .pj-chat-drawer {
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.58);
}

.pj-chat-drawer[hidden] {
  display: none;
}

.pj-chat-tri {
  height: 2px;
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--tri-a, #8eabc8), var(--tri-b, #d4bc6a), var(--tri-c, #d49a90));
}

.pj-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #d6cdc2);
  flex: 0 0 auto;
}

.pj-chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.pj-chat-title-text {
  min-width: 0;
}

.pj-chat-title {
  margin: 0;
  font-family: var(--serif, Georgia, serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
}

.pj-chat-sub {
  margin: 1px 0 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted, #5a534b);
}

.pj-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.pj-chat-btn-clear,
.pj-chat-btn-close {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line, #d6cdc2);
  background: transparent;
  color: var(--muted, #5a534b);
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pj-chat-btn-clear {
  min-height: 36px;
  padding: 0 11px;
  font-size: 12px;
}

.pj-chat-btn-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
}

.pj-chat-btn-clear:hover,
.pj-chat-btn-close:hover {
  background: var(--bg, #f4efe7);
  color: var(--ink, #1a1714);
}

.pj-chat-welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
  max-width: 96%;
  margin-top: -2px;
}

.pj-chat-chip {
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line, #d6cdc2);
  background: var(--paper, #fffdf9);
  color: var(--ink, #1a1714);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.pj-chat-chip:hover:not(:disabled) {
  border-color: var(--accent, #2c5580);
  background: var(--yellow, #f1e2a8);
  color: var(--on-yellow, #2c2408);
}

.pj-chat-chip:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pj-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.pj-chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pj-chat-msg-bot {
  align-self: flex-start;
  background: var(--bg, #f4efe7);
  color: var(--ink, #1a1714);
  border: 1px solid var(--line, #d6cdc2);
  border-bottom-left-radius: 5px;
}

.pj-chat-msg-user {
  align-self: flex-end;
  background: var(--blue, #d3e2f2);
  color: var(--on-blue, #1a3048);
  border: 1px solid transparent;
  border-bottom-right-radius: 5px;
}

.pj-chat-msg p {
  margin: 0;
}

.pj-chat-msg p + p {
  margin-top: 6px;
}

.pj-chat-msg ul,
.pj-chat-msg ol {
  margin: 6px 0 0;
  padding-left: 1.25em;
}

.pj-chat-msg li + li {
  margin-top: 4px;
}

.pj-chat-msg a {
  color: var(--accent, #2c5580);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pj-chat-handoff {
  margin-top: 8px !important;
  padding-top: 6px;
  border-top: 1px dashed var(--line, #d6cdc2);
  font-size: 13px;
}

.pj-chat-contact {
  margin: 8px 0 0;
  padding: 6px 2px 0;
  border-top: 1px dashed var(--line, #d6cdc2);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted, #5a534b);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.pj-chat-contact a {
  color: var(--accent, #2c5580);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.pj-chat-msg-typing {
  color: var(--muted, #5a534b);
  font-size: 13px;
}

.pj-chat-foot {
  border-top: 1px solid var(--line, #d6cdc2);
  padding: 12px 14px;
  background: var(--paper, #fffdf9);
  flex: 0 0 auto;
}

.pj-chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pj-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.pj-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 42px;
  max-height: 96px;
  resize: none;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line, #d6cdc2);
  background: var(--bg, #f4efe7);
  color: var(--ink, #1a1714);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.pj-chat-input::placeholder {
  color: var(--muted, #5a534b);
}

.pj-chat-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted, #5a534b);
}

.pj-chat-hint {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pj-chat-count {
  flex: 0 0 auto;
  white-space: nowrap;
  font-family: var(--mono, monospace);
  font-variant-numeric: tabular-nums;
}

.pj-chat-count.is-limit {
  color: #9a3412;
  font-weight: 600;
}

html[data-theme="dark"] .pj-chat-count.is-limit {
  color: #fca5a5;
}

.pj-chat-send {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 18px;
  white-space: nowrap;
  border-radius: 999px;
  border: 0;
  background: var(--ink, #1a1714);
  color: var(--bg, #f4efe7);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.pj-chat-send:hover:not(:disabled) {
  opacity: 0.88;
}

.pj-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  body {
    padding-bottom: 76px;
  }

  .pj-chat-fab {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    gap: 0;
    justify-content: center;
  }

  .pj-chat-fab-label {
    display: none;
  }

  .pj-chat-fab .pj-chat-fish {
    width: 24px;
    height: 12px;
  }

  .pj-chat-drawer {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    height: min(76dvh, 540px);
    max-height: calc(100dvh - 20px);
    border-radius: 18px;
  }

  .pj-chat-messages {
    padding: 12px;
  }

  .pj-chat-foot {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  .pj-chat-composer {
    gap: 8px;
  }

  .pj-chat-send {
    padding: 0 16px;
  }

  .pj-chat-meta-row {
    gap: 8px;
    flex-wrap: wrap;
  }

  .pj-chat-input {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pj-chat-fab,
  .pj-chat-btn-clear,
  .pj-chat-btn-close,
  .pj-chat-chip,
  .pj-chat-send {
    transition: none;
  }
}
