.cl-assistant {
  --assistant-forest: #082a23;
  --assistant-forest-soft: #123c32;
  --assistant-moss: #87a85c;
  --assistant-paper: #fbfaf4;
  --assistant-cream: #f1efe4;
  --assistant-ink: #14231f;
  --assistant-muted: #65716b;
  --assistant-line: rgba(8, 42, 35, 0.14);
  position: fixed;
  right: clamp(1rem, 2.6vw, 2rem);
  bottom: clamp(1rem, 2.6vw, 2rem);
  z-index: 1200;
  font-family: var(--font-body, "DM Sans", sans-serif);
}

.cl-assistant *,
.cl-assistant *::before,
.cl-assistant *::after { box-sizing: border-box; }

.cl-assistant button,
.cl-assistant textarea { font: inherit; }

.cl-assistant-launcher {
  position: relative;
  display: grid;
  width: 4.15rem;
  height: 4.15rem;
  padding: 0.45rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: var(--assistant-forest);
  box-shadow: 0 18px 46px rgba(5, 31, 26, 0.3), 0 0 0 5px rgba(251, 250, 244, 0.88);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.cl-assistant-launcher:hover {
  transform: translateY(-3px) scale(1.025);
  box-shadow: 0 24px 54px rgba(5, 31, 26, 0.36), 0 0 0 5px rgba(251, 250, 244, 0.95);
}

.cl-assistant-launcher img {
  display: block;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: contain;
}

.cl-assistant-launcher:focus-visible,
.cl-assistant button:focus-visible,
.cl-assistant textarea:focus-visible {
  outline: 3px solid rgba(135, 168, 92, 0.55);
  outline-offset: 3px;
}

.cl-assistant-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 1rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(24rem, calc(100vw - 1.5rem));
  height: min(27rem, calc(100vh - 1rem));
  max-height: calc(100vh - 1rem);
  overflow: hidden;
  border: 1px solid rgba(8, 42, 35, 0.18);
  border-radius: 1.2rem;
  color: var(--assistant-ink);
  background:
    radial-gradient(circle at 100% 0, rgba(135, 168, 92, 0.15), transparent 28%),
    linear-gradient(180deg, #fbfaf4 0%, #f7f6ef 100%);
  box-shadow: 0 30px 90px rgba(5, 31, 26, 0.28), 0 8px 24px rgba(5, 31, 26, 0.1);
  transform-origin: right bottom;
  animation: cl-assistant-enter 220ms ease both;
}

.cl-assistant-panel[hidden] { display: none; }

@keyframes cl-assistant-enter {
  from { opacity: 0; transform: translateY(0.8rem) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cl-assistant-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 4.25rem;
  padding: 0.72rem 0.85rem;
  color: #fff;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.04), transparent 38%), var(--assistant-forest);
}

.cl-assistant-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.78rem;
}

.cl-assistant-identity > img {
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.cl-assistant-head h2 {
  margin: 0.12rem 0 0;
  color: inherit;
  font-family: var(--font-display, "Syne", sans-serif);
  font-size: 0.98rem;
  line-height: 1.2;
}

.cl-assistant-head small {
  display: block;
  margin-top: 0.18rem;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.58rem;
}

.cl-assistant-kicker {
  display: block;
  color: #b3ce80;
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.cl-assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  padding: 0.72rem 0.85rem;
  overscroll-behavior: contain;
  scrollbar-color: rgba(8, 42, 35, 0.2) transparent;
  scrollbar-width: thin;
}

.cl-assistant-message {
  display: flex;
  max-width: 96%;
  align-items: flex-end;
  gap: 0.52rem;
}

.cl-assistant-message.is-user {
  align-self: flex-end;
  justify-content: flex-end;
  max-width: 86%;
}

.cl-assistant-message-avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(8, 42, 35, 0.14);
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 4px 12px rgba(5, 31, 26, 0.12);
}

.cl-assistant-message-content { min-width: 0; }

.cl-assistant-message-content > p {
  margin: 0;
  padding: 0.68rem 0.82rem;
  border: 1px solid var(--assistant-line);
  border-radius: 1rem 1rem 1rem 0.25rem;
  color: #27362f;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 7px 18px rgba(8, 42, 35, 0.055);
  font-size: 0.72rem;
  line-height: 1.5;
}

.cl-assistant-message.is-user .cl-assistant-message-content > p {
  border-color: var(--assistant-forest);
  border-radius: 1rem 1rem 0.25rem 1rem;
  color: #fff;
  background: var(--assistant-forest);
  box-shadow: 0 8px 20px rgba(8, 42, 35, 0.16);
}

.cl-assistant-message.is-loading .cl-assistant-message-content > p {
  color: var(--assistant-muted);
  background: var(--assistant-cream);
}

.cl-assistant-answer-label {
  display: block;
  margin: 0 0 0.3rem 0.25rem;
  color: var(--assistant-forest-soft);
  font-size: 0.54rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cl-assistant-source {
  display: inline-block;
  margin: 0.42rem 0 0 0.2rem;
  color: var(--assistant-forest-soft);
  font-size: 0.67rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2rem;
}

.cl-assistant-results { display: grid; gap: 0.55rem; margin-top: 0.62rem; }

.cl-assistant-result {
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  min-height: 5rem;
  overflow: hidden;
  border: 1px solid var(--assistant-line);
  border-radius: 0.82rem;
  color: inherit;
  background: rgba(255, 255, 255, 0.94);
  text-decoration: none;
  box-shadow: 0 7px 16px rgba(8, 42, 35, 0.05);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.cl-assistant-result.no-image { grid-template-columns: 1fr; }
.cl-assistant-result:hover {
  transform: translateY(-2px);
  border-color: rgba(8, 42, 35, 0.35);
  box-shadow: 0 10px 22px rgba(8, 42, 35, 0.09);
}

.cl-assistant-result img {
  width: 100%;
  height: 100%;
  min-height: 5rem;
  object-fit: contain;
  background: #e9ece4;
}

.cl-assistant-result-copy { min-width: 0; padding: 0.68rem 0.72rem; }
.cl-assistant-result-copy span {
  display: block;
  overflow: hidden;
  color: #637168;
  font-size: 0.53rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.cl-assistant-result-copy strong {
  display: -webkit-box;
  margin-top: 0.23rem;
  overflow: hidden;
  font-family: var(--font-display, "Syne", sans-serif);
  font-size: 0.72rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.cl-assistant-result-copy small {
  display: -webkit-box;
  margin-top: 0.3rem;
  overflow: hidden;
  color: #7a847f;
  font-size: 0.57rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.cl-assistant-prompt-block {
  padding: 0.52rem 0.85rem 0.56rem;
  border-top: 1px solid rgba(8, 42, 35, 0.08);
}

.cl-assistant-prompt-block > span {
  display: block;
  margin-bottom: 0.44rem;
  color: #77817c;
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cl-assistant-suggestions {
  display: flex;
  gap: 0.34rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.cl-assistant-suggestions::-webkit-scrollbar { display: none; }
.cl-assistant-suggestions button {
  flex: 0 0 auto;
  padding: 0.45rem 0.64rem;
  border: 1px solid rgba(8, 42, 35, 0.16);
  border-radius: 999px;
  color: var(--assistant-forest);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-size: 0.6rem;
  line-height: 1.2;
  transition: color 150ms ease, background 150ms ease;
}

.cl-assistant-suggestions button:hover { color: #fff; background: var(--assistant-forest-soft); }

.cl-assistant-composer {
  padding: 0.48rem 0.75rem 0.62rem;
  border-top: 1px solid var(--assistant-line);
  background: linear-gradient(180deg, rgba(251, 250, 244, 0.98), rgba(247, 244, 236, 0.98));
}

.cl-assistant-form {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.cl-assistant-form textarea {
  display: block;
  width: 100%;
  min-height: 3rem;
  max-height: 5.4rem;
  resize: none;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 3.55rem 0.9rem 1rem;
  color: var(--assistant-ink);
  background: #fff;
  font-size: 0.73rem;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(8, 42, 35, 0.05);
  transition: background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.cl-assistant-form textarea:focus {
  background: #fff;
  box-shadow: 0 10px 26px rgba(8, 42, 35, 0.08), 0 0 0 3px rgba(135, 168, 92, 0.14);
  outline: none;
}
.cl-assistant-form button {
  position: absolute;
  right: 0.58rem;
  bottom: 0.54rem;
  display: grid;
  place-items: center;
  width: 2.32rem;
  min-width: 2.32rem;
  min-height: 2.32rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(180deg, #1b5b47, #0a2f27);
  box-shadow: 0 10px 22px rgba(8, 42, 35, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.cl-assistant-form button:hover {
  background: linear-gradient(180deg, #236853, #0a2f27);
  transform: translateY(-1px);
}
.cl-assistant-form button:disabled { cursor: wait; opacity: 0.55; transform: none; }

.cl-assistant-form button svg {
  width: 0.96rem;
  height: 0.96rem;
  fill: currentColor;
}

@media (max-width: 560px) {
  .cl-assistant { right: 0.85rem; bottom: 0.85rem; }
  .cl-assistant-launcher { width: 3.9rem; height: 3.9rem; }
  .cl-assistant-panel {
    position: fixed;
    right: 0.55rem;
    left: 0.55rem;
    bottom: 0.55rem;
    top: auto;
    width: auto;
    height: min(25rem, calc(100vh - 1.1rem));
    max-height: calc(100vh - 1.1rem);
    border-radius: 1.05rem;
  }
  .cl-assistant-head { min-height: 4rem; padding: 0.68rem 0.78rem; }
  .cl-assistant-identity > img { width: 2.5rem; height: 2.5rem; }
  .cl-assistant-head h2 { font-size: 0.9rem; }
  .cl-assistant-messages { padding: 0.68rem 0.78rem; }
  .cl-assistant-message { max-width: 98%; }
  .cl-assistant-message.is-user { max-width: 90%; }
  .cl-assistant-result { grid-template-columns: 4.7rem minmax(0, 1fr); }
  .cl-assistant-prompt-block { padding: 0.48rem 0.78rem 0.52rem; }
  .cl-assistant-composer { padding: 0.42rem 0.68rem 0.56rem; }
  .cl-assistant-form textarea { min-height: 2.86rem; padding-right: 3.3rem; }
  .cl-assistant-form button { right: 0.5rem; bottom: 0.48rem; width: 2.22rem; min-width: 2.22rem; min-height: 2.22rem; }
}

@media (max-width: 370px) {
  .cl-assistant-head small { display: none; }
  .cl-assistant-panel { width: calc(100vw - 0.8rem); right: 0.4rem; left: 0.4rem; bottom: 0.4rem; height: min(23rem, calc(100vh - 0.8rem)); }
  .cl-assistant-form textarea { padding-left: 0.9rem; padding-right: 3.1rem; }
  .cl-assistant-form button { width: 2.12rem; min-width: 2.12rem; min-height: 2.12rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cl-assistant-panel { animation: none; }
  .cl-assistant-launcher,
  .cl-assistant-result,
  .cl-assistant-form button { transition: none; }
}

@media print {
  .cl-assistant { display: none !important; }
}
