#rms-wac-root {
  --rms-wac-bottom-gap: 20px;
  --rms-wac-launcher-gap: 14px;
  position: fixed;
  right: 20px;
  bottom: calc(var(--rms-wac-bottom-gap) + var(--rms-wac-bottom-offset, 0px));
  z-index: 9999;
  font-family: "Segoe UI", Tahoma, sans-serif;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: var(--rms-wac-launcher-gap);
}

#rms-wac-root.rms-wac-position-right {
  right: 20px;
  left: auto;
  align-items: flex-end;
}

#rms-wac-root.rms-wac-position-left {
  right: auto;
  left: 20px;
  align-items: flex-start;
}

#rms-wac-root[hidden],
#rms-wac-root [hidden] {
  display: none !important;
}

/* The older external chat shortcut must not cover this open conversation.
   Removing the body class restores its original styling without polling. */
body.rms-wac-chat-open .gscw-link,
body.rms-wac-chat-open .gscw-shortcut,
body.rms-wac-chat-open .gscw-modal-opener {
  display: none !important;
  pointer-events: none !important;
}

.rms-wac-launcher {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #0b3b45);
  color: #fff;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 40px rgba(11, 59, 69, 0.22);
}

.rms-wac-panel {
  /* Recompute available space with the viewport, even before resize events run. */
  --rms-wac-panel-insets: calc(var(--rms-wac-bottom-gap) + var(--rms-wac-bottom-offset, 0px)
    + var(--rms-wac-launcher-height, 46px) + var(--rms-wac-launcher-gap) + var(--rms-wac-top-inset, 0px) + 8px);
  box-sizing: border-box;
  width: min(380px, calc(100vw - 32px));
  max-height: max(0px, min(calc(100vh - 96px), calc(100vh - var(--rms-wac-panel-insets))));
  max-height: max(0px, min(calc(100vh - 96px), calc(100dvh - var(--rms-wac-panel-insets))));
  border-radius: 22px;
  overflow: hidden;
  background: #f7f5ef;
  border: 1px solid rgba(11, 59, 69, 0.12);
  box-shadow: 0 24px 60px rgba(11, 59, 69, 0.18);
  display: flex;
  flex-direction: column;
}

.rms-wac-header {
  display: flex;
  flex-shrink: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 45%),
    linear-gradient(135deg, #d8f0ea, #f2e8d5);
  border-bottom: 1px solid rgba(11, 59, 69, 0.08);
}

.rms-wac-header h2 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.2;
  color: #0b3b45;
}

.rms-wac-header p {
  margin: 0;
  color: #345b63;
  font-size: 13px;
  line-height: 1.5;
}

.rms-wac-header .rms-wac-privacy {
  margin-top: 8px;
  font-size: 12px;
  color: #5f6c72;
}

#rms-wac-root.rms-wac-has-conversation .rms-wac-header {
  justify-content: flex-end;
  min-height: 42px;
  padding: 6px 12px;
  background: #fffdf8;
}

#rms-wac-root.rms-wac-has-conversation .rms-wac-header > div {
  display: none;
}

.rms-wac-modes {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px 0;
  background: #fffdf8;
}

.rms-wac-view {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.rms-wac-modes button {
  border: 1px solid rgba(11, 59, 69, 0.16);
  border-radius: 10px;
  background: #fff;
  color: #345b63;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.rms-wac-modes button.is-active {
  background: #0b3b45;
  color: #fff;
}

.rms-wac-close {
  border: 0;
  background: transparent;
  color: #0b3b45;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.rms-wac-messages {
  min-height: 0;
  flex: 1 1 auto;
  max-height: 420px;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.rms-wac-message {
  min-width: 0;
  overflow-wrap: anywhere;
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
}

.rms-wac-input-count {
  display: block;
  color: #526267;
  font-size: 12px;
  text-align: right;
}

.rms-wac-form textarea[aria-invalid="true"] {
  outline: 2px solid #a43120;
}

.rms-wac-user {
  margin-left: auto;
  background: #0b3b45;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.rms-wac-assistant,
.rms-wac-assistant-thinking,
.rms-wac-assistant-refused,
.rms-wac-assistant-error {
  background: #fff;
  color: #1c3137;
  border: 1px solid rgba(11, 59, 69, 0.1);
  border-bottom-left-radius: 6px;
}

.rms-wac-assistant-refused {
  background: #fff7f4;
}

.rms-wac-assistant-thinking {
  color: #5f6c72;
  font-style: italic;
}

.rms-wac-answer {
  display: grid;
  gap: 8px;
  white-space: normal;
}

.rms-wac-answer p,
.rms-wac-answer ul,
.rms-wac-answer ol {
  margin: 0;
}

.rms-wac-answer ul,
.rms-wac-answer ol {
  padding-left: 20px;
}

.rms-wac-answer li + li {
  margin-top: 6px;
}

.rms-wac-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid rgba(11, 59, 69, 0.08);
  background: #fffdf8;
}

.rms-wac-form textarea,
.rms-wac-order-form input {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid rgba(11, 59, 69, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: #1c3137;
  background: #fff;
}

.rms-wac-form {
  flex: 0 0 auto;
}

.rms-wac-form textarea {
  min-height: 84px;
  resize: vertical;
}

.rms-wac-form button,
.rms-wac-order-form button {
  justify-self: end;
  border: 0;
  border-radius: 999px;
  background: #c05621;
  color: #fff;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

.rms-wac-order-view {
  padding: 16px;
  background: #fffdf8;
  overflow-y: auto;
}

.rms-wac-order-form {
  display: grid;
  gap: 12px;
}

.rms-wac-order-form label {
  display: grid;
  gap: 6px;
  color: #1c3137;
  font-size: 13px;
  font-weight: 700;
}

.rms-wac-order-result {
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid rgba(11, 59, 69, 0.1);
  background: #fff;
  padding: 12px 14px;
  color: #1c3137;
  font-size: 14px;
  line-height: 1.5;
}

.rms-wac-order-result:empty {
  display: none;
}

.rms-wac-order-result.is-error {
  background: #fff7f4;
}

.rms-wac-order-result p {
  margin: 0;
}

.rms-wac-order-result dl {
  display: grid;
  grid-template-columns: minmax(90px, max-content) 1fr;
  gap: 6px 12px;
  margin: 10px 0 0;
}

.rms-wac-order-result dt,
.rms-wac-order-result dd {
  margin: 0;
}

.rms-wac-order-result dt {
  color: #5f6c72;
  font-weight: 700;
}

.rms-wac-order-result a {
  color: #0f766e;
  text-decoration: none;
  font-weight: 700;
}

.rms-wac-citations,
.rms-wac-suggestions,
.rms-wac-handoff {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.rms-wac-citations a,
.rms-wac-suggestions a,
.rms-wac-suggestions span,
.rms-wac-handoff a {
  color: #0f766e;
  text-decoration: none;
}

.rms-wac-suggestions a,
.rms-wac-suggestions span {
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  padding: 4px 8px;
  background: #f1fbf8;
  font-weight: 700;
}

@media (max-width: 640px) {
  #rms-wac-root {
    --rms-wac-bottom-gap: 12px;
    right: 12px;
    left: 12px;
    align-items: stretch;
  }

  .rms-wac-launcher {
    width: 100%;
  }

  .rms-wac-panel {
    width: 100%;
  }
}
