.cc-chat,
.cc-chat * { box-sizing: border-box; }

.cc-chat {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10040;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.cc-chat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 28px));
  height: auto;
  max-height: min(640px, calc(100dvh - 96px));
  background: #fff;
  border: 1px solid #dce5e5;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(18, 54, 59, .18);
  overflow: hidden;
}

.cc-chat-panel[hidden],
.cc-chat-form[hidden],
.cc-chat-thread[hidden],
.cc-chat-badge[hidden],
.cc-chat-err[hidden] { display: none !important; }

.cc-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: #12363b;
  color: #fff;
}

.cc-chat-head b {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.cc-chat-sub {
  display: block;
  margin-top: 3px;
  color: #d5e4e6;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.35;
}

.cc-chat-x {
  appearance: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cc-chat-x:hover { background: rgba(255, 255, 255, .12); }

.cc-chat-form,
.cc-chat-thread {
  display: flex;
  flex-direction: column;
  flex: none;
}

.cc-chat-thread {
  height: min(440px, calc(100dvh - 200px));
  min-height: min(280px, calc(100dvh - 200px));
}

.cc-chat-form { padding: 14px 16px 16px; gap: 10px; }

.cc-chat p {
  margin: 0;
  color: #526568;
  font-size: 14px;
  line-height: 1.45;
}

.cc-chat label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  color: #12363b;
  font-size: 13px;
  font-weight: 600;
}

.cc-chat input,
.cc-chat textarea {
  width: 100%;
  border: 1px solid #dce5e5;
  border-radius: 8px;
  background: #fff;
  color: #12363b;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  padding: 10px 12px;
  box-shadow: none;
}

.cc-chat textarea { resize: vertical; min-height: 72px; }

.cc-chat input:focus,
.cc-chat textarea:focus {
  border-color: #096b73;
  outline: none;
}

.cc-chat-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.cc-chat-err { color: #b42318; font-size: 13px; }

.cc-chat-go,
.cc-chat-send button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: #096b73;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
}

.cc-chat-go:hover,
.cc-chat-send button:hover { background: #0c5961; }

.cc-chat-go:disabled,
.cc-chat-send button:disabled { opacity: .6; cursor: default; }

.cc-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: #f7fafa;
}

.cc-chat-msg { max-width: 85%; margin: 0 0 10px; }

.cc-chat-msg.mine { margin-left: auto; }

.cc-chat-msg .pad {
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e4eeee;
}

.cc-chat-msg.mine .pad {
  background: #e7f3f6;
  border-color: #d5e8ec;
}

.cc-chat-msg .who {
  margin-bottom: 2px;
  color: #78898b;
  font-size: 11px;
}

.cc-chat-msg .txt {
  margin: 0;
  color: #12363b;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cc-chat-ended {
  margin: 16px 12px 6px;
  text-align: center;
  color: #78898b;
  font-size: 12px;
  line-height: 1.3;
}

.cc-chat-send {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid #e4eeee;
  background: #fff;
}

.cc-chat-send .cc-chat-err { flex: 1 0 100%; }

.cc-chat-send textarea { flex: 1 1 160px; min-width: 0; min-height: 46px; max-height: 120px; }

.cc-chat-send button { flex: 0 0 auto; }

.cc-chat-launch {
  appearance: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: #096b73;
  color: #fff;
  box-shadow: 0 8px 24px rgba(9, 107, 115, .35);
  cursor: pointer;
}

.cc-chat-launch:hover { background: #0c5961; }

.cc-chat-launch .x { display: none; }

.cc-chat-launch[aria-expanded="true"] .bubble { display: none; }

.cc-chat-launch[aria-expanded="true"] .x { display: block; }

.cc-chat-launch.has-new { animation: cc-chat-pulse 1.4s ease-in-out 3; }

.cc-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #b42318;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes cc-chat-pulse {
  50% { box-shadow: 0 0 0 8px rgba(9, 107, 115, .2); }
}

@media (prefers-reduced-motion: reduce) {
  .cc-chat-launch.has-new { animation: none; }
}

@media print {
  .cc-chat { display: none !important; }
}
