/* ===== Chat widget (bottom-right) ===== */
.chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--terra, #a02318);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(43, 33, 24, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
  z-index: 1000;
}
.chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(43, 33, 24, 0.32);
}
.chat-fab svg { display: block; }

.chat-window {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 130px);
  background: var(--cream, #f5efe6);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(43, 33, 24, 0.30);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 1000;
  border: 1px solid var(--line, #e2d8c8);
}
.chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-head {
  background: var(--ink, #2b2118);
  color: var(--cream, #f5efe6);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-head__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--terra, #a02318);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-head__name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}
.chat-head__status {
  font-size: 12px;
  color: rgba(245, 239, 230, 0.65);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-head__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6cce58;
  display: inline-block;
}
.chat-head__close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: rgba(245, 239, 230, 0.7);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
}
.chat-head__close:hover { color: #fff; background: rgba(245, 239, 230, 0.1); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.chat-msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat-msg--them {
  background: rgba(43, 33, 24, 0.08);
  color: var(--ink, #2b2118);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-msg--me {
  background: var(--terra, #a02318);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg--status {
  align-self: center;
  background: transparent;
  color: var(--muted, #6b5e51);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
}
.chat-msg__time {
  display: block;
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line, #e2d8c8);
  background: var(--bg, #faf5ec);
}
.chat-form input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line, #d8cfc1);
  border-radius: 999px;
  background: var(--cream, #f5efe6);
  color: var(--ink, #2b2118);
  outline: none;
  min-width: 0;
}
.chat-form input:focus { border-color: var(--terra, #a02318); }
.chat-form input::placeholder { color: var(--muted, #6b5e51); }
.chat-form button {
  background: var(--terra, #a02318);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}
.chat-form button:hover { background: #8a1e15; }
.chat-form button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 700px) {
  .chat-fab { width: 52px; height: 52px; right: 14px; bottom: 14px; }
  .chat-window {
    right: 8px;
    left: 8px;
    bottom: 76px;
    width: auto;
    max-width: none;
    height: calc(100vh - 110px);
  }
}
