.buyer-chat {
  --chat-ink: #242e3c;
  --chat-muted: #565f6e;
  --chat-accent: #245c9f;
  --chat-tint: #eaf3ff;
  --chat-line: #dce3ec;
  --chat-surface: #f7f9fc;
  --chat-gutter: clamp(1.15rem, 3vw, 2rem);
  --chat-height: clamp(30rem, calc(100dvh - 9rem), 47rem);

  min-height: 100dvh;
  padding: 0 clamp(1.5rem, 6vw, 5rem) 2.5rem;
  color: var(--chat-ink);
  background:
    radial-gradient(ellipse at 87% 0%, #e9f2ff 0, transparent 58%),
    linear-gradient(145deg, #fcfbf8 25%, #f1f5fa);
}

.buyer-chat__masthead,
.buyer-chat__layout {
  width: min(100%, 80rem);
  margin-inline: auto;
}

.buyer-chat__masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5.4rem;
  margin-bottom: clamp(1rem, 2.5vh, 2rem);
}

.buyer-chat__masthead a {
  display: inline-flex;
}

.buyer-chat__masthead .brand-mark {
  width: 1.55rem;
  height: 1.95rem;
}

.buyer-chat__masthead .brand-word {
  font-size: 2rem;
}

.buyer-chat__tagline {
  color: var(--chat-muted);
  font-size: .85rem;
  font-weight: 700;
}

.buyer-chat__layout {
  display: grid;
  grid-template-columns: minmax(15rem, .95fr) minmax(0, 2.2fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
}

.buyer-chat__storefront {
  display: grid;
  align-self: start;
  gap: 1.4rem;
  min-width: 0;
}

.buyer-chat__storefront + .buyer-chat__panel {
  align-self: start;
}

.buyer-chat__profile {
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 1.35rem;
  background: var(--white);
}

.buyer-chat__store-cover {
  height: clamp(6.25rem, 10vw, 8rem);
  background:
    radial-gradient(ellipse at 85% 135%, #c8ddf8 0 40%, transparent 41%),
    radial-gradient(ellipse at 98% 110%, #e3efff 0 58%, transparent 59%),
    linear-gradient(130deg, #f2f7ff, #d6e8ff);
}

.buyer-chat__store-cover img,
.buyer-chat__product-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.buyer-chat__profile-body {
  position: relative;
  padding: 0 1.2rem 1.2rem;
}

.buyer-chat__profile-body .buyer-chat__profile-avatar {
  width: 4.2rem;
  height: 4.2rem;
  margin: -2.1rem 0 .8rem;
  border: .25rem solid var(--white);
  border-radius: 1.25rem;
}

.buyer-chat__profile-avatar .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.buyer-chat__kicker {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--chat-accent);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.buyer-chat__profile h2 {
  margin-block: .35rem .45rem;
  font-size: clamp(1.5rem, 2.3vw, 2.15rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.buyer-chat__about {
  color: var(--chat-muted);
  overflow-wrap: anywhere;
}

.buyer-chat__reputation {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .85rem;
  padding-top: .75rem;
  border-top: 1px solid var(--chat-line);
  color: var(--chat-muted);
  font-size: .85rem;
}

.buyer-chat__reputation strong {
  color: var(--chat-ink);
}

.buyer-chat__reputation > .icon {
  color: #8d540c;
  fill: #ffe2aa;
}

.buyer-chat__reputation a {
  display: grid;
  place-items: center;
  min-width: 2rem;
  min-height: 2rem;
  margin-left: auto;
  border-radius: .4rem;
  color: var(--chat-accent);
}

.buyer-chat__storefront h3 {
  margin-bottom: .65rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.015em;
}

.buyer-chat__featured {
  display: grid;
  gap: .45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.buyer-chat__product {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .7rem;
  padding: .45rem .6rem;
  border: 1px solid var(--chat-line);
  border-radius: .8rem;
  background: #ffffffc9;
  text-align: left;
}

.buyer-chat__product:not(:disabled):hover,
.buyer-chat__reputation a:hover {
  background: var(--chat-tint);
}

.buyer-chat__product-image {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  overflow: hidden;
  border-radius: .55rem;
  background: var(--chat-tint);
  color: var(--chat-accent);
}

.buyer-chat__product-info strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.buyer-chat__product-info small {
  display: block;
  margin-top: .12rem;
  color: var(--chat-muted);
  font-size: .84rem;
}

.buyer-chat__catalog-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.8rem;
  margin-top: .25rem;
  color: var(--chat-accent);
  font-size: .9rem;
  font-weight: 800;
}

.buyer-chat__catalog-link:hover {
  text-decoration: underline;
}

.buyer-chat__reputation .icon,
.buyer-chat__product > .icon,
.buyer-chat__catalog-link .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.buyer-chat__owner {
  min-width: 0;
}

.buyer-chat__owner h2 {
  margin-block: .75rem;
  font-size: clamp(1.8rem, 3.2vw, 3rem);
  font-weight: 800;
}

.buyer-chat__owner > p:not(.buyer-chat__kicker) {
  color: var(--chat-muted);
}

.buyer-chat__kicker .icon,
.buyer-chat__owner-link .icon {
  width: 1rem;
  height: 1rem;
}

.buyer-chat__channels {
  margin-top: 1.25rem;
}

.buyer-chat__channels h3 {
  font-size: .92rem;
  font-weight: 800;
  letter-spacing: 0;
}

.buyer-chat__channels ul {
  display: grid;
  gap: .25rem;
  margin: .55rem 0 0;
  padding: 0;
  list-style: none;
}

.buyer-chat__channels li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: .6rem;
  align-items: center;
  padding: .45rem .6rem;
  border: 1px solid var(--chat-line);
  border-radius: .7rem;
  background: #ffffffb3;
  font-weight: 800;
}

.buyer-chat__channels li .icon {
  grid-row: span 2;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--chat-accent);
}

.buyer-chat__channels small {
  color: var(--chat-muted);
  font-size: .76rem;
  font-weight: 600;
}

.buyer-chat__owner-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  margin-top: .8rem;
  color: var(--chat-accent);
  font-size: .85rem;
  font-weight: 800;
}

.buyer-chat__owner-link:hover {
  text-decoration: underline;
}

.buyer-chat__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: var(--chat-height);
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 1.75rem;
  background: var(--white);
  box-shadow: 0 1.6rem 4rem -2.3rem #233a5d55, 0 .2rem .7rem #233a5d09;
}

.buyer-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
  padding: .9rem var(--chat-gutter);
  border-bottom: 1px solid var(--chat-line);
}

.buyer-chat__identity {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-width: 0;
}

.buyer-chat__avatar,
.buyer-chat__welcome-icon {
  display: grid;
  place-items: center;
  color: var(--chat-accent);
  background: var(--chat-tint);
}

.buyer-chat__avatar {
  width: 3.1rem;
  height: 3.1rem;
  flex: 0 0 3.1rem;
  border-radius: .95rem;
  overflow: hidden;
}

.buyer-chat__avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.buyer-chat__store {
  min-width: 0;
}

.buyer-chat__store h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 800;
  letter-spacing: -.03em;
}

.buyer-chat__store p,
.buyer-chat__web,
.buyer-chat__note {
  color: var(--chat-muted);
  font-size: .78rem;
}

.buyer-chat__web {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border: 1px solid var(--chat-line);
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 700;
}

.buyer-chat__web .icon {
  width: 1rem;
  height: 1rem;
}

.buyer-chat__transcript {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.buyer-chat__viewport {
  height: 100%;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  background: var(--chat-surface);
}

.buyer-chat__viewport:focus-visible {
  outline-offset: -3px;
}

.buyer-chat__content {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.15rem var(--chat-gutter);
}

.buyer-chat__welcome {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .75rem;
  margin: auto;
  padding: 1.15rem 0;
  text-align: center;
}

.buyer-chat__welcome-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: .35rem;
  border: 1px solid #d9e8fb;
  border-radius: 1.3rem;
}

.buyer-chat__welcome-icon .icon {
  width: 1.8rem;
  height: 1.8rem;
}

.buyer-chat__welcome h1,
.buyer-chat__welcome h2 {
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
}

.buyer-chat__welcome p {
  max-width: 33ch;
  color: var(--chat-muted);
  line-height: 1.55;
}

.buyer-chat__welcome .buyer-chat__primary {
  margin-top: .55rem;
}

.buyer-chat__unavailable {
  min-height: 22rem;
}

.buyer-chat__messages {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.buyer-chat__message {
  align-self: flex-start;
  min-width: 0;
  max-width: min(94%, 39rem);
  padding: .65rem .85rem .75rem;
  border: 1px solid var(--chat-line);
  border-radius: .95rem .95rem .95rem .3rem;
  background: var(--white);
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.buyer-chat__message--buyer {
  align-self: flex-end;
  border-color: #d5e5fa;
  border-radius: .95rem .95rem .3rem .95rem;
  background: var(--chat-tint);
}

.buyer-chat__speaker {
  margin-bottom: .28rem;
  color: var(--chat-muted);
  font-size: .75rem;
  font-weight: 800;
}

.buyer-chat__message--buyer .buyer-chat__speaker {
  color: var(--chat-accent);
}

.buyer-chat__block + .buyer-chat__block {
  margin-top: .6rem;
}

.buyer-chat__text {
  white-space: pre-wrap;
}

.buyer-chat__photo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(15rem, 38dvh);
  margin-bottom: .6rem;
  border-radius: .55rem;
  object-fit: contain;
}

.buyer-chat__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}

.buyer-chat__actions > *,
.buyer-chat__code button,
.buyer-chat__latest {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 2.6rem;
  max-width: 100%;
  padding: .3rem .65rem;
  color: var(--chat-accent);
  background: var(--white);
  border: 1px solid #d5e4f8;
  border-radius: .65rem;
  text-align: left;
  font-size: .9rem;
  font-weight: 800;
}

.buyer-chat__actions > *:hover,
.buyer-chat__code button:hover,
.buyer-chat__latest:hover {
  background: var(--chat-tint);
}

.buyer-chat__actions .icon,
.buyer-chat__code .icon,
.buyer-chat__latest .icon {
  width: 1rem;
  height: 1rem;
}

.buyer-chat__code {
  padding: .65rem .75rem;
  border: 1px solid var(--chat-line);
  border-radius: .7rem;
  background: var(--chat-surface);
}

.buyer-chat__code code {
  display: block;
  margin-bottom: .55rem;
  font-size: .9rem;
  user-select: all;
  overflow-wrap: anywhere;
}

.buyer-chat__latest {
  position: absolute;
  right: var(--chat-gutter);
  bottom: .65rem;
  box-shadow: 0 .25rem 1rem #233a5d1a;
}

.buyer-chat__latest[hidden] {
  display: none;
}

.buyer-chat__pending {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-top: .65rem;
  color: var(--chat-muted);
  font-size: .82rem;
  font-weight: 700;
}

.buyer-chat__pending span {
  display: inline-flex;
  gap: .2rem;
}

.buyer-chat__pending i {
  width: .3rem;
  height: .3rem;
  border-radius: 50%;
  background: var(--chat-accent);
}

.buyer-chat__footer {
  padding: .85rem var(--chat-gutter) max(.55rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--chat-line);
}

#buyer-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .45rem;
  padding: .25rem;
  border: 1px solid var(--chat-line);
  border-radius: .95rem;
  background: var(--chat-surface);
}

#buyer-chat-form:focus-within {
  border-color: var(--chat-accent);
}

.buyer-chat__input {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: .35rem .7rem;
  border: 0;
  border-radius: .65rem;
  outline-offset: -2px;
  background: transparent;
  font-size: 16px;
}

.buyer-chat__input::placeholder {
  color: var(--chat-muted);
  opacity: 1;
}

.buyer-chat__primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 3rem;
  min-width: 3rem;
  padding: .4rem .85rem;
  color: white;
  background: var(--chat-accent);
  border-radius: .7rem;
  font-weight: 800;
}

.buyer-chat__primary:hover {
  background: #1c4b85;
}

.buyer-chat button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.buyer-chat__send {
  padding: 0;
}

.buyer-chat__note {
  margin-top: .45rem;
  text-align: center;
}

.buyer-chat__error {
  margin-bottom: .35rem;
  color: #9d2533;
  font-size: .85rem;
}

.owner-preview {
  width: min(100% - 2rem, 34rem);
  margin: clamp(1rem, 8dvh, 5rem) auto;
}

.owner-preview__card,
.owner-preview__form {
  display: grid;
  gap: .8rem;
}

.owner-preview__card {
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--white);
}

.owner-preview__challenge {
  padding: .7rem;
  border-radius: .55rem;
  background: var(--paper);
  overflow-wrap: anywhere;
  user-select: all;
}

@media (max-width: 52rem) {
  .buyer-chat {
    --chat-gutter: 1.15rem;
    --chat-height: max(23rem, calc(100dvh - 4.9rem));
    padding: 0 .65rem .65rem;
  }

  .buyer-chat__masthead {
    min-height: 4.25rem;
    margin-bottom: 0;
    padding-inline: .5rem;
  }

  .buyer-chat__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: .65rem;
  }

  .buyer-chat__layout:has(.buyer-chat__owner) {
    height: var(--chat-height);
    grid-template-rows: auto minmax(23rem, 1fr);
    align-items: stretch;
  }

  .buyer-chat__storefront {
    display: none;
  }

  .buyer-chat__owner {
    padding: .6rem .5rem;
  }

  .buyer-chat__owner h2 {
    margin-block: .4rem;
    font-size: 1.4rem;
  }

  .buyer-chat__owner > p:not(.buyer-chat__kicker) {
    font-size: .86rem;
  }

  .buyer-chat__channels {
    margin-top: .7rem;
  }

  .buyer-chat__channels ul {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .buyer-chat__channels li {
    display: block;
    padding: .4rem;
    font-size: .84rem;
  }

  .buyer-chat__channels li .icon {
    display: none;
  }

  .buyer-chat__channels small {
    display: block;
    line-height: 1.25;
  }

  .buyer-chat__owner + .buyer-chat__panel {
    height: auto;
  }

  .buyer-chat__panel {
    border-radius: 1.15rem;
  }

  .buyer-chat__message {
    max-width: 96%;
  }
}

@media (max-width: 27rem) {
  .buyer-chat {
    --chat-gutter: .85rem;
  }

  .buyer-chat__web {
    display: none;
  }
}
