.rubi-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  border: 1px solid rgba(255, 235, 186, 0.72);
  border-radius: 999px;
  background: linear-gradient(135deg, #f3ca77 0%, #d9a74f 100%);
  color: #11181c;
  box-shadow: 0 10px 28px rgba(217, 167, 79, 0.4), 0 0 0 1px rgba(255, 235, 186, 0.2);
  padding: 13px 20px;
  font: 800 15px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.rubi-launcher::before {
  content: "";
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2311181c' d='M12 3C6.49 3 2 6.81 2 11.5c0 2.54 1.34 4.87 3.69 6.46L4.5 22l4.36-2.18c1.01.24 2.07.36 3.14.36 5.51 0 10-3.81 10-8.68S17.51 3 12 3Z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.rubi-launcher:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow: 0 13px 34px rgba(217, 167, 79, 0.5), 0 0 0 1px rgba(255, 239, 199, 0.3);
}

.rubi-launcher:active {
  transform: translateY(0);
}

.rubi-launcher:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.rubi-chat button:focus-visible,
.rubi-chat input:focus-visible,
.rubi-chat textarea:focus-visible {
  outline: 3px solid #f2b544;
  outline-offset: 2px;
}

.rubi-chat {
  position: fixed;
  right: 20px;
  bottom: 82px;
  z-index: 9999;
  width: min(380px, calc(100vw - 24px));
  height: min(610px, calc(100vh - 110px));
  display: none;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  border: 1px solid #d7e0e8;
  border-radius: 16px;
  box-shadow: 0 18px 55px rgba(15, 35, 55, 0.3);
  overflow: hidden;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1e2d3d;
}

.rubi-chat.is-open { display: grid; }
.rubi-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: #123b63; color: #fff; }
.rubi-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #f2b544; color: #123b63; font-weight: 800; }
.rubi-title { min-width: 0; flex: 1; }
.rubi-title strong,
.rubi-title small { display: block; }
.rubi-title small { opacity: 0.82; }
.rubi-end { border: 1px solid rgba(255, 255, 255, 0.7); border-radius: 7px; background: transparent; color: #fff; padding: 5px 7px; font: 700 11px/1 system-ui; cursor: pointer; }
.rubi-close { border: 0; background: transparent; color: #fff; font-size: 24px; cursor: pointer; }
.rubi-messages { overflow: auto; padding: 14px; background: #f5f8fb; }
.rubi-welcome { padding: 5px 3px; }
.rubi-welcome p:first-child { margin: 0 0 15px; font-size: 15px; font-weight: 600; color: #173e61; }
.rubi-welcome label { display: grid; gap: 5px; margin: 0 0 11px; font-weight: 700; color: #334b60; }
.rubi-welcome input,
.rubi-welcome textarea { width: 100%; box-sizing: border-box; border: 1px solid #bac8d4; border-radius: 8px; padding: 10px; font: inherit; font-weight: 400; }
.rubi-welcome textarea { min-height: 72px; max-height: 120px; resize: vertical; }
.rubi-optional { font-size: 11px; font-weight: 400; color: #65727e; }
.rubi-start { width: 100%; border: 0; border-radius: 8px; background: #123b63; color: #fff; padding: 11px; font-weight: 700; cursor: pointer; }
.rubi-welcome-note { margin: 11px 0 0; font-size: 11px; color: #65727e; }
.rubi-row { display: flex; margin: 0 0 10px; }
.rubi-row.user { justify-content: flex-end; }
.rubi-bubble { max-width: 84%; padding: 9px 11px; border-radius: 13px; background: #fff; border: 1px solid #dce4eb; white-space: pre-wrap; overflow-wrap: anywhere; }
.rubi-row.user .rubi-bubble { background: #123b63; color: #fff; border-color: #123b63; }
.rubi-row.system .rubi-bubble { background: #fff8e8; border-color: #efd59a; }
.rubi-meta { display: block; margin-top: 4px; font-size: 11px; opacity: 0.66; }
.rubi-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 12px; }
.rubi-quick button,
.rubi-action { border: 1px solid #2c6692; border-radius: 999px; background: #fff; color: #174b73; padding: 7px 10px; cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.2; }
.rubi-composer { border-top: 1px solid #dde5ec; background: #fff; padding: 10px; }
.rubi-inputrow { display: flex; gap: 8px; align-items: flex-end; }
.rubi-composer textarea { min-height: 42px; max-height: 105px; resize: none; flex: 1; border: 1px solid #bac8d4; border-radius: 10px; padding: 10px; font: inherit; }
.rubi-send { border: 0; border-radius: 10px; background: #123b63; color: #fff; padding: 11px 14px; font-weight: 700; cursor: pointer; }
.rubi-send:disabled { opacity: 0.55; cursor: not-allowed; }
.rubi-status { min-height: 18px; margin-top: 6px; color: #5a6875; font-size: 12px; }
.rubi-form { display: grid; gap: 8px; margin-top: 9px; }
.rubi-form input,
.rubi-form textarea { width: 100%; box-sizing: border-box; border: 1px solid #bac8d4; border-radius: 8px; padding: 9px; font: inherit; }
.rubi-form button { border: 0; border-radius: 8px; background: #16724c; color: #fff; padding: 10px; font-weight: 700; cursor: pointer; }
.rubi-turnstile { min-height: 0; }
.rubi-privacy { font-size: 11px; color: #65727e; margin: 7px 0 0; }
.rubi-hidden { display: none !important; }

@media (max-width: 520px) {
  .rubi-launcher {
    right: 12px;
    bottom: 12px;
    gap: 7px;
    min-height: 44px;
    padding: 11px 16px;
    font-size: 14px;
  }

  .rubi-launcher::before {
    width: 16px;
    height: 16px;
  }

  .rubi-chat {
    inset: 8px;
    width: auto;
    height: auto;
    border-radius: 14px;
  }

  .rubi-chat.is-open { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .rubi-launcher { transition: none; }
}
