@font-face {
  font-family: "Nunito";
  src: url("__OPI_FRAME_FONT_ASSET_URL__") format("truetype");
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --font-sans-rounded: "Nunito", ui-rounded, "SF Pro Rounded", "Arial Rounded MT", Arial, Helvetica, sans-serif;
  --opi-accent: #007aff;
  --opi-surface: #ffffff;
  --opi-panel-bg: #ffffff;
  --opi-panel-border: #e5e7eb;
  --opi-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  --opi-header-bg: #007aff;
  --opi-header-ink: #ffffff;
  --opi-text: #1f2937;
  --opi-muted: #6b7280;
  --opi-soft-muted: #9ca3af;
  --opi-user-bubble: #dbeafe;
  --opi-bot-bubble: #f3f4f6;
  --opi-footer-bg: #f9fafb;
  --opi-status-pending: #0ea5e9;
  --opi-status-processing: #f59e0b;
  --opi-status-ready: #6366f1;
  --opi-status-delivered: #16a34a;
  --opi-status-failed: #dc2626;
}

html,
body,
#opi-frame-root {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
}

html,
body {
  overflow: hidden;
}

body,
button,
input,
textarea,
select {
  color: var(--opi-text);
  font-family: var(--font-sans-rounded);
  background: var(--opi-panel-bg);
}

#opi-frame-root {
  background: var(--opi-panel-bg);
}

.opi-chat-shell {
  height: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--opi-panel-bg);
}

.opi-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--opi-header-bg);
  color: var(--opi-header-ink);
}

.opi-chat-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.opi-chat-ring {
  --opi-ring-scale: 1;
  --opi-ring-core-inset: 6px;
  --opi-ring-shadow: 0 0 8px rgba(168, 216, 255, 0.6), 0 0 18px rgba(255, 214, 232, 0.28);
  --opi-ring-filter: drop-shadow(0 0 5px rgba(220, 242, 255, 0.28)) drop-shadow(0 0 11px rgba(118, 191, 255, 0.18)) saturate(1);
  --opi-ring-bloom-opacity: 0.14;
  --opi-ring-bloom-scale: 1.05;
  --opi-ring-bloom-blur: 7px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  flex: 0 0 auto;
  position: relative;
  isolation: isolate;
  background: conic-gradient(
    from 0deg,
    #a8d8ff 0deg,
    #ffd6e8 60deg,
    #fff5cc 120deg,
    #ffe4cc 180deg,
    #ffd6e8 240deg,
    #a8d8ff 300deg,
    #a8d8ff 360deg
  );
  box-shadow: var(--opi-ring-shadow);
  filter: var(--opi-ring-filter);
  transform: scale(var(--opi-ring-scale));
  transform-origin: center center;
  transition: transform 70ms ease-out, box-shadow 90ms ease-out, filter 90ms ease-out;
  will-change: transform, box-shadow, filter;
}

.opi-chat-ring::before {
  content: "";
  position: absolute;
  inset: var(--opi-ring-core-inset);
  border-radius: 999px;
  background: #ffffff;
  transition: inset 70ms ease-out, box-shadow 90ms ease-out;
}

.opi-chat-ring::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(250, 253, 255, 0.98) 0%,
    rgba(226, 244, 255, 0.82) 22%,
    rgba(168, 222, 255, 0.52) 44%,
    rgba(102, 184, 255, 0.2) 62%,
    rgba(102, 184, 255, 0) 76%
  );
  opacity: var(--opi-ring-bloom-opacity);
  transform: scale(var(--opi-ring-bloom-scale));
  filter: blur(var(--opi-ring-bloom-blur));
  transform-origin: center center;
  transition: opacity 90ms ease-out, transform 70ms ease-out, filter 90ms ease-out;
  pointer-events: none;
  z-index: -1;
}

.opi-chat-heading {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.opi-chat-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: inherit;
  line-height: 1.2;
}

.opi-chat-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  line-height: 1.45;
}

.opi-chat-thread-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.opi-transcript {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 12px;
  box-sizing: border-box;
  overscroll-behavior-y: contain;
}

.opi-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 16px;
  text-align: center;
  box-sizing: border-box;
}

.opi-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--opi-soft-muted);
}

.opi-empty-copy {
  display: none;
}

.opi-entry {
  display: grid;
  gap: 4px;
}

.opi-row {
  display: flex;
  width: 100%;
}

.opi-row-user {
  justify-content: flex-end;
}

.opi-row-assistant {
  justify-content: flex-start;
}

.opi-bubble {
  display: grid;
  gap: 8px;
  width: fit-content;
  max-width: 95%;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.05);
  color: rgba(15, 23, 42, 0.82);
  background: var(--opi-bot-bubble);
}

.opi-bubble-user {
  background: var(--opi-user-bubble);
  color: #1a1a1a;
  gap: 2px;
  padding: 5px 6px 4px 14px;
  border-radius: 12px 12px 0 12px;
  border-color: rgba(14, 165, 233, 0.15);
}

.opi-bubble-assistant {
  border-radius: 12px 12px 12px 0;
}

.opi-bubble-body {
  display: grid;
  gap: 10px;
  font-size: 15px;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.opi-bubble-body p,
.opi-bubble-body ul,
.opi-bubble-body ol,
.opi-bubble-body blockquote,
.opi-bubble-body pre {
  margin: 0;
}

.opi-bubble-body ul,
.opi-bubble-body ol {
  padding-left: 20px;
}

.opi-bubble-body code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

.opi-bubble-body pre {
  overflow-x: auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.06);
}

.opi-bubble-body pre code {
  display: block;
  padding: 0;
  background: transparent;
}

.opi-bubble-body blockquote {
  padding-left: 12px;
  color: var(--opi-muted);
  border-left: 3px solid rgba(15, 23, 42, 0.18);
}

.opi-bubble-body .opi-link-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 4px 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 122, 255, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(239, 246, 255, 0.92) 100%);
  color: var(--opi-accent);
  font-family: var(--font-sans-rounded);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(0, 122, 255, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.opi-bubble-body .opi-link-button::after {
  content: "Abrir";
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.12);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.opi-bubble-body .opi-link-button:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 122, 255, 0.34);
  box-shadow: 0 14px 28px rgba(0, 122, 255, 0.14);
}

.opi-bubble-body .opi-link-button:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.24);
  outline-offset: 2px;
}

.opi-transport-status {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-self: flex-end;
  margin: 0;
  min-height: 14px;
  padding: 0;
  max-width: none;
  position: relative;
}

.opi-transport-status-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 140ms ease, transform 140ms ease;
}

.opi-transport-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.08);
  transition: background-color 140ms ease, opacity 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.opi-transport-status[data-dots="1"] .opi-transport-status-dot:last-child {
  opacity: 0;
  transform: scale(0.2);
}

.opi-transport-status[data-tone="read"] .opi-transport-status-dot {
  background: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12);
}

.opi-transport-status[data-tone="failed"] .opi-transport-status-dot {
  background: #cbd5e1;
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.1);
}

.opi-transport-status[hidden] {
  display: none;
}

.opi-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  margin: 0 12px 12px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.opi-typing-indicator[hidden] {
  display: none;
}

.opi-typing-avatar {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  position: relative;
  flex: 0 0 auto;
  background: conic-gradient(
    from 0deg,
    #a8d8ff 0deg,
    #ffd6e8 60deg,
    #fff5cc 120deg,
    #ffe4cc 180deg,
    #ffd6e8 240deg,
    #a8d8ff 300deg,
    #a8d8ff 360deg
  );
  box-shadow: 0 0 6px rgba(168, 216, 255, 0.5);
}

.opi-typing-avatar::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  background: #ffffff;
}

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

.opi-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--opi-accent);
  animation: opi-typing-bounce 1.4s ease-in-out infinite;
}

.opi-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.opi-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes opi-typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.opi-typing-copy {
  font-size: 14px;
  color: var(--opi-muted);
}

.opi-reset-countdown {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 0 12px 12px;
  padding: 14px 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(219, 234, 254, 0.9), rgba(255, 255, 255, 0) 58%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 255, 0.95));
  border: 1px solid rgba(19, 103, 229, 0.14);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.opi-reset-countdown-gauge {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.98) 0 58%, transparent 59%),
    conic-gradient(from 180deg, rgba(19, 103, 229, 0.18), rgba(19, 103, 229, 0.8), rgba(91, 179, 255, 0.4));
  box-shadow: inset 0 0 0 1px rgba(19, 103, 229, 0.08);
}

.opi-reset-countdown-gauge::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.96);
}

.opi-reset-countdown-value {
  position: relative;
  z-index: 1;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: #1367e5;
}

.opi-reset-countdown-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.opi-reset-countdown-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4b77c5;
}

.opi-reset-countdown-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--opi-text);
}

.opi-reset-countdown-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--opi-muted);
}

.opi-reset-countdown-progress {
  position: relative;
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: rgba(19, 103, 229, 0.12);
}

.opi-reset-countdown-progress-fill {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  background: linear-gradient(90deg, #5bb3ff 0%, #1367e5 100%);
  transition: transform 180ms linear;
}

.opi-reset-countdown.is-imminent {
  border-color: rgba(59, 130, 246, 0.24);
  box-shadow: 0 14px 30px rgba(19, 103, 229, 0.14);
}

.opi-reset-countdown.is-imminent .opi-reset-countdown-value {
  color: #0f5cd6;
}

.opi-suggestions-shell {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 150ms ease-out;
}

.opi-suggestions-shell.is-collapsed {
  grid-template-rows: 0fr;
}

.opi-suggestions-shell.is-collapsed .opi-suggestions-inner {
  opacity: 0;
  transform: translateY(-6px);
}

.opi-suggestions-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 12px 10px;
  display: grid;
  gap: 8px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.opi-suggestions-label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--opi-muted);
}

.opi-suggestion-list {
  display: grid;
  gap: 6px;
}

.opi-suggestion-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  color: var(--opi-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.opi-suggestion-button:hover {
  background: #f8fafc;
  border-color: #dbe3ee;
  transform: translateY(-1px);
}

.opi-suggestion-button.is-selected {
  background: #e8f2ff;
  border-color: rgba(19, 103, 229, 0.28);
  color: #1367e5;
}

.opi-suggestion-copy {
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
}

.opi-suggestion-arrow {
  flex: 0 0 auto;
  color: currentColor;
  font-size: 13px;
}

.opi-chat-composer {
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--opi-panel-border);
  background: var(--opi-footer-bg);
}

.opi-composer-frame {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease;
}

.opi-composer-frame:focus-within {
  box-shadow: 0 2px 12px rgba(0, 122, 255, 0.15), inset 0 0 0 1px rgba(0, 122, 255, 0.3);
}

.opi-composer-input {
  flex: 1 1 auto;
  min-height: 20px;
  max-height: 160px;
  padding: 4px 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: #333333;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  box-sizing: border-box;
  overflow-y: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.opi-composer-input::placeholder {
  color: var(--opi-soft-muted);
}

.opi-composer-input::-webkit-scrollbar {
  width: 4px;
}

.opi-composer-input::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
}

.opi-composer-input::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.opi-send-button {
  position: relative;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  cursor: pointer;
  background: #e8f2ff;
  color: #1367e5;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.opi-send-button:hover {
  background: #deebff;
  transform: scale(1.05);
}

.opi-send-button:active {
  background: #d4e7ff;
  transform: scale(0.95);
}

.opi-send-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.opi-send-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.opi-send-button.is-pending {
  pointer-events: none;
}

.opi-send-button.is-pending .opi-send-icon {
  opacity: 0;
}

.opi-send-button.is-pending::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(19, 103, 229, 0.25);
  border-top-color: #1367e5;
  border-radius: 999px;
  animation: opi-send-spin 0.8s linear infinite;
}

@keyframes opi-send-spin {
  to {
    transform: rotate(360deg);
  }
}

.opi-composer-footer {
  min-height: 14px;
}

.opi-status-line {
  font-size: 11px;
  color: var(--opi-soft-muted);
  text-align: center;
  padding: 0 8px;
}

.opi-status-line[hidden] {
  display: none;
}

.opi-frame-fallback {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  box-sizing: border-box;
}

.opi-frame-fallback-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.opi-frame-fallback-copy {
  margin: 0;
  color: var(--opi-muted);
  font-size: 14px;
  line-height: 1.5;
}

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

@media (max-width: 768px) {
  .opi-reset-countdown {
    margin: 0 10px 10px;
    padding: 13px 14px;
    gap: 12px;
  }

  .opi-reset-countdown-gauge {
    width: 48px;
    height: 48px;
  }

  .opi-reset-countdown-value {
    font-size: 19px;
  }

  .opi-chat-header {
    padding: 12px 14px;
  }

  .opi-transcript {
    padding: 10px;
  }

  .opi-suggestions-inner {
    padding: 0 10px 10px;
  }

  .opi-chat-composer {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .opi-reset-countdown-progress-fill,
  .opi-suggestions-shell,
  .opi-suggestions-inner,
  .opi-suggestion-button,
  .opi-composer-frame,
  .opi-send-button {
    transition: none;
  }

  .opi-typing-dots span {
    animation: none;
    opacity: 0.8;
  }
}
