:root {
  color-scheme: light;
  --ink: #19201d;
  --muted: #66706b;
  --surface: #ffffff;
  --soft: #f1f5f2;
  --line: #d7dfda;
  --brand: #e94724;
  --brand-dark: #9d2017;
  --green: #006f4e;
  --shadow: 0 24px 70px rgba(25, 32, 29, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 14% 12%, rgba(233, 71, 36, 0.09), transparent 30rem),
    linear-gradient(135deg, #f9f8f4 0%, #eef3ef 100%);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(233, 71, 36, 0.25);
  outline-offset: 2px;
}

.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;
}

.aidas-shell {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(330px, 460px) 380px;
  align-items: end;
  gap: 14px;
  max-width: calc(100vw - 48px);
  transform-origin: right bottom;
  transition: opacity 160ms ease, transform 220ms ease;
}

.aidas-shell:not(.is-open) {
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
}

.chat-panel,
.product-panel {
  overflow: hidden;
  border: 1px solid rgba(25, 32, 29, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
  width: 380px;
  height: min(680px, calc(100vh - 48px));
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-dark), var(--brand));
}

.brand-mark,
.avatar,
.launcher {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  font-weight: 800;
  background: var(--brand);
  border-radius: 50%;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.16);
}

.chat-header__copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.chat-header__copy strong {
  font-size: 16px;
}

.chat-header__copy span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #92e7b9;
  box-shadow: 0 0 0 4px rgba(146, 231, 185, 0.14);
}

.icon-button,
.modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.launcher[hidden] {
  display: none;
}

.icon-button {
  color: #fff;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.12);
}

.chat-log {
  overflow-y: auto;
  padding: 18px 16px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

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

.avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.message {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 14px;
}

.message p {
  margin: 0;
  white-space: pre-wrap;
}

.message--assistant {
  background: var(--soft);
  border-bottom-left-radius: 5px;
}

.message-row--assistant:has(.inline-recommendations) .message {
  max-width: calc(100% - 38px);
}

.inline-recommendations {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.inline-product {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.inline-product img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 9px;
  background: var(--soft);
}

.inline-product > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.inline-product strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-product span,
.product-reason {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.inline-product__actions {
  display: flex;
  gap: 6px;
}

.inline-product__actions button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #b7c5be;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.inline-product__actions .inline-interest-button {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.message--user {
  color: #fff;
  background: var(--brand);
  border-bottom-right-radius: 5px;
}

.message--error {
  color: #7b1d15;
  background: #fff0ed;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7d8782;
  animation: pulse 900ms infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 130ms;
}

.typing i:nth-child(3) {
  animation-delay: 260ms;
}

@keyframes pulse {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
  35% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin: 0 14px;
  padding: 9px 10px 9px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.composer:focus-within {
  border-color: rgba(233, 71, 36, 0.55);
  box-shadow: 0 0 0 3px rgba(233, 71, 36, 0.09);
}

.composer textarea {
  flex: 1;
  min-height: 26px;
  max-height: 112px;
  padding: 3px 0;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.send-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  cursor: pointer;
}

.send-button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.privacy-copy {
  margin: 8px 14px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
}

.product-panel {
  width: min(460px, calc(100vw - 442px));
  max-height: min(680px, calc(100vh - 48px));
}

.product-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.product-panel h2,
.interest-modal h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.result-count {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--green);
  background: #e8f4ef;
  font-size: 11px;
  white-space: nowrap;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  max-height: 600px;
  padding: 14px;
}

.product-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.product-card.is-active,
.product-card:hover {
  border-color: rgba(0, 111, 78, 0.55);
  box-shadow: 0 10px 24px rgba(0, 111, 78, 0.11);
  transform: translateY(-2px);
}

.product-card__image {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--soft);
}

.product-rank {
  position: absolute;
  z-index: 1;
  top: 9px;
  left: 9px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 12px rgba(0, 79, 56, 0.18);
  font-size: 10px;
  font-weight: 800;
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-card__placeholder {
  color: var(--muted);
  font-size: 12px;
}

.product-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.product-card h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.product-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  color: #46504b;
  background: var(--soft);
  font-size: 10px;
}

.product-actions {
  display: grid;
  gap: 7px;
  margin-top: auto;
}

.product-link,
.interest-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.product-link {
  color: #fff;
  background: var(--green);
}

.interest-button {
  border: 1px solid #aab8b1;
  color: var(--ink);
  background: #fff;
}

.interest-button:disabled {
  color: var(--green);
  border-color: #b7d9cb;
  background: #edf8f3;
  cursor: default;
}

.launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 41;
  width: 60px;
  height: 60px;
  border: 0;
  box-shadow: 0 16px 34px rgba(157, 32, 23, 0.28);
  cursor: pointer;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 22, 18, 0.55);
  backdrop-filter: blur(5px);
}

.modal-backdrop[hidden] {
  display: none;
}

.interest-modal {
  position: relative;
  width: min(480px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 26px;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--ink);
  font-size: 23px;
  background: var(--soft);
}

.selected-product {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.interest-modal form,
.interest-modal label {
  display: grid;
  gap: 7px;
}

.interest-modal form {
  gap: 14px;
}

.interest-modal label {
  color: #3f4844;
  font-size: 12px;
  font-weight: 700;
}

.interest-modal input,
.interest-modal select,
.interest-modal textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-weight: 400;
}

.interest-modal textarea {
  resize: vertical;
}

.primary-button {
  border: 0;
  color: #fff;
  background: var(--brand);
}

.form-status {
  min-height: 18px;
  margin: 0;
  color: #8d2c20;
  font-size: 12px;
}

@media (max-width: 820px) {
  .aidas-shell {
    inset: 10px;
    grid-template-columns: 1fr;
    align-content: end;
    max-width: none;
  }

  .chat-panel {
    width: 100%;
    height: min(620px, calc(100vh - 20px));
  }

  .product-panel {
    display: none !important;
  }

  .inline-product__actions button:not(.inline-interest-button) {
    display: none;
  }

  .inline-interest-button {
    width: 100%;
  }

  .launcher {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .aidas-shell {
    inset: 0;
  }

  .chat-panel {
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .chat-header {
    padding-top: max(14px, env(safe-area-inset-top));
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
