/* Center Notes live chat widget */
.cn-chat-bubble {
  position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 9990;
  width: 56px; height: 56px; border-radius: 50%;
  background: #2D5A43; color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(45, 90, 67, 0.35);
}
.cn-chat-bubble svg { width: 26px; height: 26px; }
.cn-chat-bubble:hover { transform: scale(1.06); }
.cn-chat-dot {
  position: absolute; top: 2px; right: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #DC503C; border: 2px solid #fff;
}
.cn-chat-panel {
  position: fixed; right: 1.2rem; bottom: 5.2rem; z-index: 9990;
  width: min(360px, calc(100vw - 2.4rem)); height: 480px; max-height: calc(100vh - 7rem);
  background: #fff; border: 1px solid #e5dccb; border-radius: 16px;
  box-shadow: 0 16px 48px rgba(60, 50, 30, 0.18);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
}
.cn-chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.8rem 1rem; background: #2D5A43; color: #fff; font-size: 0.95rem;
}
.cn-chat-close { background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; }
.cn-chat-body { display: none; }
.cn-chat-welcome { font-size: 0.85rem; color: #6f675c; margin: 0 0 0.8rem; line-height: 1.45; }
.cn-chat-start { padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.cn-chat-input {
  width: 100%; padding: 0.55rem 0.75rem; border: 1.5px solid #e5dccb; border-radius: 8px;
  font-size: 0.9rem; box-sizing: border-box;
}
.cn-chat-thread {
  flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem;
  background: #faf7f0;
}
.cn-chat-msg { max-width: 85%; }
.cn-chat-msg.me { align-self: flex-end; }
.cn-chat-msg.them, .cn-chat-msg.ai { align-self: flex-start; }
.cn-chat-sender { font-size: 0.7rem; font-weight: 700; color: #6f675c; margin-bottom: 0.15rem; }
.cn-chat-ai-tag {
  display: inline-block; background: #e3ecf5; color: #2b5a8a; font-size: 0.62rem;
  padding: 0 0.35rem; border-radius: 4px; margin-right: 0.25rem; vertical-align: 1px;
}
.cn-chat-text {
  padding: 0.55rem 0.8rem; border-radius: 12px; font-size: 0.88rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.cn-chat-msg.me .cn-chat-text { background: #2D5A43; color: #fff; border-bottom-right-radius: 4px; }
.cn-chat-msg.them .cn-chat-text { background: #fff; border: 1px solid #e5dccb; border-bottom-left-radius: 4px; }
.cn-chat-msg.ai .cn-chat-text { background: #eef3f8; border: 1px solid #d4e0ec; border-bottom-left-radius: 4px; }
.cn-chat-composer { display: flex; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid #e5dccb; background: #fff; }
.cn-chat-composer .cn-chat-input { flex: 1; }
/* The `hidden` attribute must win over the display:flex rules above,
   or the panel can never be closed/minimized and the start/thread/composer
   sections never swap. */
.cn-chat-panel[hidden],
.cn-chat-start[hidden],
.cn-chat-thread[hidden],
.cn-chat-composer[hidden] { display: none !important; }
.cn-chat-endrow { padding: 0.35rem 0.9rem 0.65rem; text-align: center; background: #fff; border-top: 1px solid #f0e9da; }
.cn-chat-endbtn { background: none; border: 0; color: #a39a8b; font-size: 0.75rem; text-decoration: underline; cursor: pointer; padding: 0.2rem 0.5rem; }
.cn-chat-endbtn:hover { color: #6f675c; }
.cn-chat-endrow[hidden] { display: none !important; }
