#hemi-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --hemi-ink: #16162a;
  --hemi-accent: #2b2b52;
  --hemi-accent-light: #3d3d70;
  --hemi-bg: #f6f6fb;
  --hemi-border: #e6e6f0;
}

#hemi-chat-root[data-hemi-inline="1"] {
  position: static;
  right: auto;
  bottom: auto;
  max-width: 480px;
}

.hemi-bubble {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: linear-gradient(150deg, var(--hemi-accent-light), var(--hemi-ink));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(22, 22, 42, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, visibility 0.15s;
}
.hemi-bubble svg {
  width: 24px;
  height: 24px;
}
.hemi-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(22, 22, 42, 0.4);
}
.hemi-bubble--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.9);
}
.hemi-bubble--typing {
  animation: hemi-bubble-pulse 1.4s infinite ease-in-out;
}
@keyframes hemi-bubble-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(22, 22, 42, 0.35), 0 0 0 0 rgba(61, 61, 112, 0.5); }
  50% { box-shadow: 0 6px 20px rgba(22, 22, 42, 0.35), 0 0 0 8px rgba(61, 61, 112, 0); }
}

.hemi-bubble-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  border: 2px solid #fff;
}
.hemi-bubble-badge:empty {
  display: none;
}
.hemi-bubble-badge--count {
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.hemi-panel {
  /* Absolute (not static) so the closed-but-still-laid-out panel never
     inflates #hemi-chat-root's own box -- that inflation was pushing the
     bubble (an earlier sibling in flow) up away from the bottom-right
     corner it's supposed to anchor to. Only the floating (non-inline)
     panel needs this; .hemi-panel--inline overrides back to static below. */
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(22, 22, 42, 0.28);
  overflow: hidden;
  overscroll-behavior: contain;
  transform-origin: bottom right;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
}
.hemi-panel--closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.97);
}
.hemi-panel--inline {
  position: static;
  width: 100%;
  height: 560px;
  max-height: none;
  box-shadow: 0 1px 8px rgba(22, 22, 42, 0.12);
  border: 1px solid var(--hemi-border);
  transform-origin: center;
}

.hemi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(120deg, var(--hemi-accent), var(--hemi-ink));
  color: #fff;
}
.hemi-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.hemi-header-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
}
.hemi-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hemi-header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.hemi-header-title {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
}
.hemi-header-subtitle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.2;
}
.hemi-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.25);
  flex: none;
}
.hemi-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}
.hemi-header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  flex: none;
  transition: background 0.12s ease;
}
.hemi-header-icon-btn svg {
  width: 16px;
  height: 16px;
}
.hemi-header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.hemi-share-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #f0f0f8;
  border-bottom: 1px solid var(--hemi-border);
}
.hemi-share-form--hidden {
  display: none;
}
.hemi-share-input {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--hemi-border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
}
.hemi-share-input:focus {
  outline: none;
  border-color: var(--hemi-accent-light);
}
.hemi-share-send {
  background: var(--hemi-accent-light);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.hemi-share-send:disabled {
  opacity: 0.5;
  cursor: default;
}
.hemi-share-status {
  flex-basis: 100%;
  font-size: 11.5px;
  color: #6b6b80;
  min-height: 14px;
}
.hemi-share-status--success {
  color: #16a34a;
}
.hemi-share-status--error {
  color: #b91c1c;
}

.hemi-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--hemi-bg);
}
.hemi-messages::-webkit-scrollbar {
  width: 6px;
}
.hemi-messages::-webkit-scrollbar-thumb {
  background: #d6d6e4;
  border-radius: 3px;
}

.hemi-message {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.46;
  word-break: break-word;
}
.hemi-message--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--hemi-accent-light), var(--hemi-ink));
  color: #fff;
  border-bottom-right-radius: 5px;
  white-space: pre-wrap;
}
.hemi-message--assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--hemi-ink);
  border: 1px solid var(--hemi-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 3px rgba(22, 22, 42, 0.04);
}

/* Markdown-lite rendering inside assistant bubbles */
.hemi-md-p {
  margin: 0;
}
.hemi-md-p + .hemi-md-p,
.hemi-md-heading + .hemi-md-p,
.hemi-md-p + .hemi-md-heading,
.hemi-md-list + .hemi-md-p,
.hemi-md-p + .hemi-md-list {
  margin-top: 8px;
}
.hemi-md-heading {
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 2px;
}
.hemi-md-heading:first-child {
  margin-top: 0;
}
.hemi-md-heading--1 { font-size: 15.5px; }
.hemi-md-heading--2 { font-size: 15px; }
.hemi-md-heading--3,
.hemi-md-heading--4 { font-size: 14px; opacity: 0.85; }
.hemi-md-list {
  margin: 6px 0 0;
  padding-left: 20px;
}
.hemi-md-list + .hemi-md-list {
  margin-top: 2px;
}
.hemi-md-list li {
  margin: 2px 0;
}
.hemi-md-table-wrap {
  margin: 6px 0 0;
  /* The chat panel is only ~340px of usable width -- a 3+ column table
     needs to scroll horizontally in its own box rather than force the
     whole message bubble (and page) wider. */
  max-width: 100%;
  overflow-x: auto;
}
.hemi-md-p + .hemi-md-table-wrap,
.hemi-md-table-wrap + .hemi-md-p,
.hemi-md-table-wrap + .hemi-md-list,
.hemi-md-list + .hemi-md-table-wrap {
  margin-top: 8px;
}
.hemi-md-table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.hemi-md-table th,
.hemi-md-table td {
  padding: 4px 8px;
  border: 1px solid var(--hemi-border);
  text-align: left;
}
.hemi-md-table th {
  background: #f0f0f8;
  font-weight: 700;
}
.hemi-message--user .hemi-md-table th,
.hemi-message--user .hemi-md-table td {
  border-color: rgba(255, 255, 255, 0.3);
}
.hemi-message--user .hemi-md-table th {
  background: rgba(255, 255, 255, 0.12);
}
.hemi-md-code {
  background: #eeeef6;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.hemi-md-link {
  color: var(--hemi-accent-light);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hemi-message--user .hemi-md-link {
  color: #fff;
}

.hemi-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 13px 15px;
}
.hemi-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b0b0c4;
  animation: hemi-typing-bounce 1.2s infinite ease-in-out;
}
.hemi-typing span:nth-child(2) { animation-delay: 0.15s; }
.hemi-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hemi-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.hemi-suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}
.hemi-chip {
  background: #fff;
  border: 1px solid var(--hemi-border);
  color: var(--hemi-ink);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.hemi-chip:hover {
  background: #eeeef8;
  border-color: #cfcfe2;
}

.hemi-products {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.hemi-product-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--hemi-border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.hemi-product-card:hover {
  box-shadow: 0 4px 14px rgba(22, 22, 42, 0.12);
  transform: translateY(-1px);
}
.hemi-product-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.hemi-product-link img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f0f0f5;
}
.hemi-product-body {
  padding: 9px 10px;
}
.hemi-product-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hemi-product-price {
  font-size: 12.5px;
  color: var(--hemi-ink);
  font-weight: 700;
}
.hemi-product-unavailable {
  font-size: 11px;
  color: #b91c1c;
  margin-top: 2px;
}

.hemi-product-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 10px 10px;
}
.hemi-color-swatch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hemi-border);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--hemi-ink);
  text-decoration: none;
  background: #f9f9fd;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.hemi-color-swatch:hover {
  background: #eeeef8;
  border-color: #cfcfe2;
}
.hemi-color-swatch--unavailable {
  color: #9a9aab;
  text-decoration: line-through;
}
.hemi-color-swatch--more {
  color: #9a9aab;
  background: transparent;
  border-style: dashed;
}

.hemi-error {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 9px 13px;
  align-self: flex-start;
}
.hemi-retry {
  background: #b91c1c;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
}

.hemi-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--hemi-border);
  background: #fff;
}
.hemi-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--hemi-border);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.3;
  max-height: 76px;
  transition: border-color 0.12s ease;
}
.hemi-input:focus {
  outline: none;
  border-color: var(--hemi-accent-light);
}
.hemi-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  background: linear-gradient(135deg, var(--hemi-accent-light), var(--hemi-ink));
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.12s ease, transform 0.1s ease;
}
.hemi-send svg {
  width: 15px;
  height: 15px;
}
.hemi-send:hover {
  transform: translateY(-1px);
}
.hemi-send:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

@media (max-width: 480px) {
  #hemi-chat-root {
    right: 12px;
    bottom: 12px;
  }
  .hemi-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
  }
}
