.chatw {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 200;
  font-family: "Inter", sans-serif;
}

.chatw-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--rust);
  color: var(--paper);
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(28, 31, 27, 0.28);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.chatw-toggle:hover {
  background: var(--rust-2);
  transform: scale(1.06);
}

.chatw-panel {
  position: absolute;
  left: 0;
  bottom: 72px;
  width: min(360px, calc(100vw - 2.5rem));
  max-height: 72vh;
  background: var(--paper);
  border: 1px solid var(--line-dark);
  border-radius: 0.6rem;
  box-shadow: 0 24px 60px rgba(28, 31, 27, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatw-panel[hidden] {
  display: none;
}

.chatw-quick[hidden],
.chatw-input-row[hidden],
.chatw-boq[hidden] {
  display: none;
}

.chatw-header {
  background: var(--steel);
  color: var(--paper);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatw-title {
  margin: 0;
  font-family: "Big Shoulders Display", sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chatw-sub {
  margin: 0.2rem 0 0;
  font-size: 0.68rem;
  opacity: 0.72;
  font-family: "IBM Plex Mono", monospace;
}

.chatw-close {
  background: transparent;
  border: none;
  color: var(--paper);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
}

.chatw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 200px;
}

.chatw-msg {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 0.55rem;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.chatw-msg.user {
  align-self: flex-end;
  background: var(--rust-2);
  color: var(--paper);
  border-bottom-right-radius: 0.15rem;
}

.chatw-msg.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line-dark);
  border-bottom-left-radius: 0.15rem;
}

.chatw-msg.system {
  align-self: center;
  background: transparent;
  color: var(--steel);
  opacity: 0.72;
  font-size: 0.75rem;
  font-family: "IBM Plex Mono", monospace;
  text-align: center;
  max-width: 100%;
}

.chatw-typing {
  align-self: flex-start;
  display: flex;
  gap: 0.25rem;
  padding: 0.55rem 0.75rem;
}

.chatw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--steel);
  opacity: 0.4;
  animation: chatw-bounce 1.2s infinite ease-in-out;
}

.chatw-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.chatw-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatw-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chatw-quick {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.9rem 0.7rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.chatw-quick button,
.chatw-quick a {
  border: 1px solid var(--line-dark);
  background: #fff;
  color: var(--steel);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
  padding: 0.4rem 0.6rem;
  border-radius: 0.3rem;
  cursor: pointer;
  text-decoration: none;
}

.chatw-quick button:hover,
.chatw-quick a:hover {
  border-color: var(--rust);
  color: var(--rust);
}

.chatw-input-row {
  display: flex;
  border-top: 1px solid var(--line-dark);
  padding: 0.6rem;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chatw-input-row input {
  flex: 1;
  border: 1px solid #d2ccbc;
  border-radius: 0.3rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
}

.chatw-input-row input:focus {
  outline: 2px solid rgba(187, 77, 38, 0.3);
  border-color: var(--rust);
}

.chatw-input-row button {
  width: 42px;
  border: none;
  border-radius: 0.3rem;
  background: var(--rust-2);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.chatw-input-row button:hover {
  background: #7c2f16;
}

.chatw-input-row button:disabled,
.chatw-input-row input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatw-boq {
  padding: 0.9rem;
  border-top: 1px solid var(--line-dark);
  display: grid;
  gap: 0.45rem;
  background: #fff;
  overflow-y: auto;
  max-height: 60vh;
  min-height: 0;
  flex-shrink: 1;
}

.chatw-boq[hidden] {
  display: none;
}

.chatw-boq label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chatw-boq input[type="text"],
.chatw-boq input[type="email"],
.chatw-boq input[type="tel"],
.chatw-boq textarea {
  width: 100%;
  border: 1px solid #d2ccbc;
  border-radius: 0.3rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
}

.chatw-boq input:focus,
.chatw-boq textarea:focus {
  outline: 2px solid rgba(187, 77, 38, 0.3);
  border-color: var(--rust);
}

.chatw-boq textarea {
  resize: vertical;
  min-height: 60px;
}

.chatw-file-hint {
  margin: -0.2rem 0 0;
  font-size: 0.66rem;
  opacity: 0.65;
}

.chatw-boq-status {
  min-height: 1rem;
  margin: 0;
  font-size: 0.75rem;
}

.chatw-boq-status.error {
  color: #b3261e;
}

.chatw-boq-status.success {
  color: #2f7d3c;
}

.chatw-boq-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.chatw-boq-actions button {
  flex: 1;
  padding: 0.6rem;
  border-radius: 0.3rem;
  border: 1px solid transparent;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
}

.chatw-boq-submit {
  background: var(--rust-2);
  color: var(--paper);
}

.chatw-boq-submit:hover {
  background: #7c2f16;
}

.chatw-boq-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatw-boq-cancel {
  background: transparent;
  border-color: var(--line-dark);
  color: var(--steel);
}

@media (max-width: 480px) {
  .chatw {
    left: 0.75rem;
    bottom: 0.75rem;
  }

  .chatw-panel {
    width: calc(100vw - 1.5rem);
  }
}
