:root {
  --chat-bg: #101010;
  --chat-panel: #141414;
  --chat-glass: rgba(16, 16, 16, 0.55);
  --chat-border: rgba(255, 255, 255, 0.12);
  --chat-text: #f5f5f5;
  --chat-muted: #b7b7b7;
  --chat-accent: #d4842a;
  --chat-accent-strong: #b86a1f;
  --chat-accent-text: #140d06;
  --chat-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

#chat-widget {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  font-family: inherit;
}

#chat-widget,
#chat-widget * {
  box-sizing: border-box;
}

#chat-widget .hidden {
  display: none !important;
}

#chat-fab {
  position: relative;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 56px !important;
  height: 56px !important;
  padding: 0 !important;
  border-radius: 18px !important;
  border: 1px solid var(--chat-border) !important;
  background: var(--chat-glass) !important;
  color: #ffffff !important;
  box-shadow: var(--chat-shadow) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer !important;
  line-height: 1 !important;
  text-decoration: none !important;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

#chat-fab:hover {
  background: rgba(20, 20, 20, 0.85) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  transform: scale(0.97);
}

#chat-fab:focus-visible {
  outline: 2px solid rgba(212, 132, 42, 0.7);
  outline-offset: 3px;
}

#chat-fab .chat-fab-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#chat-fab svg {
  display: block !important;
}

#chat-badge {
  position: absolute !important;
  right: -6px !important;
  top: -6px !important;
  min-width: 18px !important;
  height: 18px !important;
  padding: 0 5px !important;
  border-radius: 999px !important;
  border: 2px solid rgba(16, 16, 16, 0.95) !important;
  background: #ff3b30 !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
}

#chat-badge[data-dot="1"] {
  min-width: 12px !important;
  height: 12px !important;
  padding: 0 !important;
  font-size: 0 !important;
}

#chat-widget.is-open #chat-fab {
  display: none !important;
}

#chat-window {
  width: 380px;
  height: min(600px, 78vh);
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  margin-bottom: 12px;
}

@media (max-width: 420px) {
  #chat-window {
    width: calc(100vw - 24px);
    height: min(680px, 82vh);
  }
}

#chat-header {
  flex: 0 0 auto;
  padding: 14px;
  background: rgba(16, 16, 16, 0.45);
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#chat-title {
  font-weight: 800;
  color: #fff;
  line-height: 1.05;
  font-size: 18px;
  letter-spacing: -0.6px;
}

#chat-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--chat-muted);
  margin-top: 4px;
  letter-spacing: -0.3px;
}

#chat-subtitle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.18);
}

#chat-close {
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: rgba(245, 245, 245, 0.65) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-size: 26px !important;
  line-height: 1 !important;
  border-radius: 12px !important;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

#chat-close:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  transform: scale(0.97);
}

#chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  background:
    radial-gradient(700px 280px at 15% 0%, rgba(212, 132, 42, 0.1), transparent 60%),
    linear-gradient(180deg, rgba(212, 132, 42, 0.04), transparent 45%);
}

.msg {
  max-width: 86%;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.2px;
}

.msg.operator {
  margin-right: auto;
  background: rgba(42, 42, 42, 0.85);
  color: #fff;
}

.msg.user {
  margin-left: auto;
  background: var(--chat-accent);
  color: var(--chat-accent-text);
  border-color: transparent;
}

.msg.system {
  max-width: 100%;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(245, 245, 245, 0.75);
  border-style: dashed;
}

.msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-meta {
  font-size: 12px;
  opacity: 0.65;
  margin-top: 8px;
}

#chat-input {
  flex: 0 0 auto;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--chat-border);
  background: rgba(16, 16, 16, 0.45);
}

#chat-text {
  flex: 1 !important;
  width: auto !important;
  min-width: 0 !important;
  color: #fff !important;
  background: rgba(16, 16, 16, 0.55) !important;
  border: 1px solid var(--chat-border) !important;
  border-radius: 14px !important;
  padding: 12px 14px !important;
  height: 46px !important;
  outline: none !important;
  box-shadow: none !important;
  font: inherit !important;
  letter-spacing: -0.4px !important;
  line-height: 1.2 !important;
  caret-color: #fff !important;
}

#chat-text::placeholder {
  color: rgba(183, 183, 183, 0.65) !important;
}

#chat-text:focus {
  border-color: rgba(212, 132, 42, 0.45) !important;
}

#chat-send {
  width: 46px !important;
  height: 46px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 14px !important;
  border: 0 !important;
  background: var(--chat-accent) !important;
  color: var(--chat-accent-text) !important;
  cursor: pointer !important;
  line-height: 1 !important;
  box-shadow: none !important;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

#chat-send:hover {
  background: var(--chat-accent-strong) !important;
  transform: scale(0.97);
}

#chat-send:focus-visible {
  outline: 2px solid rgba(212, 132, 42, 0.7);
  outline-offset: 3px;
}

#chat-send svg {
  display: block !important;
}

@media (max-width: 360px) {
  #chat-window {
    border-radius: 20px;
  }
}
