.oac-widget,
.oac-widget * {
  box-sizing: border-box;
}

.oac-widget {
  --oac-brand: rgb(0, 69, 104);
  --oac-brand-hover: #005a8c;
  --oac-accent: #007cba;
  --oac-panel: #ffffff;
  --oac-surface: #f8fafc;
  --oac-border: #e4e8ec;
  --oac-text: #333333;
  --oac-muted: #63747e;
  --oac-assistant: rgb(206, 240, 255);
  --oac-danger: #9b1c1c;
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 2147483000;
  color: var(--oac-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.oac-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  display: flex;
  visibility: hidden;
  flex-direction: column;
  width: min(350px, calc(100vw - 40px));
  min-width: min(350px, calc(100vw - 40px));
  max-width: min(700px, calc(100vw - 40px));
  height: min(550px, calc(100vh - 60px));
  height: min(550px, calc(100dvh - 60px));
  min-height: min(550px, calc(100vh - 60px));
  min-height: min(550px, calc(100dvh - 60px));
  max-height: calc(100vh - 60px);
  max-height: calc(100dvh - 60px);
  overflow: hidden;
  border: 1px solid var(--oac-border);
  border-radius: 12px;
  background: var(--oac-panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: scale(0.985);
  transform-origin: top right;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms linear;
}

.oac-widget.is-open .oac-panel {
  visibility: visible;
  opacity: 1;
  transform: scale(1);
}

.oac-resize-handle {
  position: absolute;
  left: 2px;
  bottom: 2px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 0 8px 0 8px;
  background: transparent;
  color: var(--oac-muted);
  cursor: nesw-resize;
  opacity: 0.55;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 160ms ease, background-color 160ms ease;
}

.oac-resize-handle:hover,
.oac-resize-handle:focus-visible,
.oac-widget.is-resizing .oac-resize-handle {
  background: rgba(0, 69, 104, 0.08);
  color: var(--oac-brand);
  opacity: 1;
}

.oac-resize-handle:focus-visible {
  outline: 2px solid var(--oac-accent);
  outline-offset: -2px;
}

.oac-resize-handle .oac-icon {
  width: 18px;
  height: 18px;
}

.oac-widget.is-resizing,
.oac-widget.is-resizing * {
  cursor: nesw-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.oac-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--oac-accent);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 300ms ease, transform 300ms ease, background-color 300ms ease;
}

.oac-toggle:hover,
.oac-toggle:focus-visible {
  background: var(--oac-accent);
  opacity: 1;
  transform: scale(1.05);
}

.oac-widget.is-open .oac-toggle {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.oac-toggle .oac-icon {
  width: 24px;
  height: 24px;
}

.oac-toggle .oac-icon path:first-child {
  fill: currentColor;
  stroke: currentColor;
}

.oac-toggle .oac-icon path:last-child {
  fill: none;
  stroke: var(--oac-accent);
  stroke-width: 2.8;
}

.oac-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--oac-brand);
  color: #ffffff;
  font-size: 16px;
  font-weight: 400;
}

.oac-title {
  margin: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
}

.oac-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oac-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
}

.oac-icon-button:hover,
.oac-icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.oac-icon-button .oac-icon {
  width: 16px;
  height: 16px;
}

.oac-icon {
  display: block;
  flex: 0 0 auto;
}

.oac-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
  background-color: var(--oac-surface);
  background-image:
    linear-gradient(rgba(248, 250, 252, 0.88), rgba(248, 250, 252, 0.88)),
    url("../images/mbio-logo-background.png");
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: 100% 100%, clamp(210px, 55%, 360px) auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.oac-log {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oac-message {
  display: flex;
  width: 100%;
  flex-direction: column;
}

.oac-bubble {
  position: relative;
  max-width: 90%;
  margin-right: auto;
  padding: 12px 16px;
  border: 1px solid var(--oac-border);
  border-radius: 15px 15px 15px 0;
  background: var(--oac-assistant);
  color: var(--oac-text);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  box-shadow: none;
}

.oac-message--user .oac-bubble {
  margin-right: 0;
  margin-left: auto;
  border-color: var(--oac-accent);
  border-radius: 15px 15px 0 15px;
  background: var(--oac-accent);
  color: #ffffff;
}

.oac-message-label {
  display: none;
}

.oac-message--assistant:not(.oac-message--typing) .oac-message-label {
  display: inline;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: inherit;
  opacity: 1;
}

.oac-message--assistant:not(.oac-message--typing) .oac-message-text {
  display: inline;
}

.oac-message-text {
  min-width: 0;
  white-space: normal;
}

.oac-message--streaming .oac-message-text {
  white-space: pre-wrap;
}

.oac-message-text a {
  color: #005a8c;
  font-weight: 500;
  text-decoration: none;
}

.oac-message-text a:hover {
  text-decoration: underline;
}

.oac-message--user .oac-message-text a {
  color: #ffffff;
}

.oac-message-text strong {
  font-weight: 700;
}

.oac-message-text em {
  font-style: italic;
}

.oac-message--streaming .oac-message-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--oac-brand);
  vertical-align: -0.12em;
  animation: oac-typewriter-caret 800ms steps(1, end) infinite;
}

@keyframes oac-typewriter-caret {
  0%,
  45% {
    opacity: 1;
  }
  46%,
  100% {
    opacity: 0;
  }
}

.oac-message-text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 69, 104, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
}

.oac-message--user .oac-message-text code {
  background: rgba(255, 255, 255, 0.18);
}


.oac-message-text p {
  margin: 0.65em 0 0;
}

.oac-message-text h1,
.oac-message-text h2,
.oac-message-text h3,
.oac-message-text h4,
.oac-message-text h5,
.oac-message-text h6 {
  margin: 0.85em 0 0.35em;
  color: inherit;
  font-weight: 700;
  line-height: 1.25;
}

.oac-message-text h1 {
  font-size: 1.35em;
}

.oac-message-text h2 {
  font-size: 1.25em;
}

.oac-message-text h3 {
  font-size: 1.15em;
}

.oac-message-text h4,
.oac-message-text h5,
.oac-message-text h6 {
  font-size: 1.05em;
}

.oac-message-text ul,
.oac-message-text ol {
  margin: 0.65em 0 0.25em;
  padding-left: 1.45em;
}

.oac-message-text li {
  margin: 0.22em 0;
}

.oac-message-text li > p:first-child {
  margin-top: 0;
}

.oac-message-text blockquote {
  margin: 0.7em 0 0.25em;
  padding: 0.15em 0 0.15em 0.75em;
  border-left: 3px solid rgba(0, 69, 104, 0.35);
  color: #425466;
}

.oac-message--user .oac-message-text blockquote {
  border-left-color: rgba(255, 255, 255, 0.65);
  color: inherit;
}

.oac-message-text hr {
  height: 1px;
  margin: 0.8em 0;
  border: 0;
  background: var(--oac-border);
}

.oac-message-text pre {
  max-width: 100%;
  margin: 0.7em 0 0.25em;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid rgba(0, 69, 104, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.75);
  white-space: pre;
  tab-size: 4;
}

.oac-message-text pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 0.88em;
  white-space: pre;
}

.oac-message--user .oac-message-text pre {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.12);
}

.oac-message-text del {
  text-decoration-thickness: 1px;
}

.oac-message-text img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.7em 0 0.25em;
  border-radius: 7px;
}

.oac-table-wrap {
  max-width: 100%;
  margin: 0.7em 0 0.25em;
  overflow-x: auto;
  border: 1px solid var(--oac-border);
  border-radius: 7px;
}

.oac-message-text table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.92em;
}

.oac-message-text th,
.oac-message-text td {
  padding: 6px 8px;
  border-right: 1px solid var(--oac-border);
  border-bottom: 1px solid var(--oac-border);
  vertical-align: top;
}

.oac-message-text th:last-child,
.oac-message-text td:last-child {
  border-right: 0;
}

.oac-message-text tr:last-child td {
  border-bottom: 0;
}

.oac-message-text th {
  background: rgba(0, 69, 104, 0.08);
  font-weight: 700;
}

.oac-message--user .oac-table-wrap,
.oac-message--user .oac-message-text th,
.oac-message--user .oac-message-text td {
  border-color: rgba(255, 255, 255, 0.3);
}

.oac-message--user .oac-message-text table,
.oac-message--user .oac-message-text th {
  background: rgba(0, 0, 0, 0.08);
}

.oac-task-list {
  padding-left: 0 !important;
  list-style: none;
}

.oac-task-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.4em;
}

.oac-task-list-item > input[type="checkbox"] {
  width: 1em;
  height: 1em;
  margin: 0.28em 0 0;
  accent-color: var(--oac-accent);
}

.oac-task-list-item > ul,
.oac-task-list-item > ol,
.oac-task-list-item > p {
  flex-basis: 100%;
  margin-left: 1.4em;
}

.oac-notice {
  align-self: center;
  max-width: 95%;
  padding: 7px 10px;
  border-radius: 7px;
  background: #e8eef2;
  color: var(--oac-muted);
  font-size: 12px;
  text-align: center;
}

.oac-notice--error {
  border: 1px solid #efb2b2;
  background: #fff0f0;
  color: var(--oac-danger);
}

.oac-message--typing .oac-bubble {
  display: flex;
  align-items: center;
  padding: 12px 16px;
}

.oac-message--typing .oac-bubble::before {
  content: "mBioWorks:";
  margin-right: 7px;
  font-weight: 700;
}

.oac-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

.oac-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff69b4;
  opacity: 0.75;
  animation: oac-bounce 1.2s infinite ease-in-out;
}

.oac-typing-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.oac-typing-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes oac-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.oac-form {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--oac-border);
  background: var(--oac-panel);
}

.oac-compose-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.oac-input {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  margin: 0;
  padding: 8px 12px;
  resize: none;
  overflow-y: auto;
  border: 1px solid var(--oac-border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--oac-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.oac-input:focus {
  border-color: var(--oac-accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.oac-input:disabled {
  background: #f0f2f4;
}

.oac-send {
  flex: 0 0 auto;
  min-height: 36px;
  margin: 0;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--oac-brand);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background-color 200ms ease, transform 200ms ease;
}

.oac-send:hover,
.oac-send:focus-visible {
  background: var(--oac-brand-hover);
  transform: translateY(-1px);
}

.oac-send:disabled {
  background: #cccccc;
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.oac-privacy {
  margin: 7px 2px 0;
  color: var(--oac-muted);
  font-size: 10px;
  font-style: italic;
  line-height: 1.35;
  text-align: right;
}

.oac-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.oac-icon-button:focus-visible,
.oac-toggle:focus-visible,
.oac-send:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .oac-widget,
  .oac-panel {
    right: 12px;
  }

  .oac-panel {
    width: min(350px, calc(100vw - 24px));
    min-width: min(350px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .oac-panel,
  .oac-toggle,
  .oac-input,
  .oac-send,
  .oac-resize-handle {
    transition: none;
  }

  .oac-typing-dots span,
  .oac-message--streaming .oac-message-text::after {
    animation: none;
  }

  .oac-typing-dots span {
    opacity: 0.75;
  }
}
