.motion-showcase {
  display: grid;
  grid-template-columns: minmax(8.5rem, 0.82fr) minmax(0, 1.45fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  height: 22rem;
  margin: 1rem 0 0.35rem;
}

.motion-item {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0.45rem;
  background: #f2f2f2;
}

.motion-item--robot {
  grid-row: 1 / 3;
}

.motion-item video,
.motion-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 320ms ease, opacity 180ms ease;
}

.motion-item--robot video {
  object-position: center center;
}

.motion-item--lego video {
  object-position: center 52%;
}

.motion-item--sf img {
  object-position: center 12%;
}

.motion-copy {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 1.1rem;
  place-items: center;
  color: #161616;
  background: #f4f3ef;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.008rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.2rem);
  transition: opacity 180ms ease, transform 220ms ease;
}

.motion-item:focus-visible video,
.motion-item:focus-visible img {
  opacity: 0;
  transform: scale(1.018);
}

.motion-item:focus-visible .motion-copy {
  opacity: 1;
  transform: translateY(0);
}

.motion-item:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .motion-item:hover video,
  .motion-item:hover img {
    opacity: 0;
    transform: scale(1.018);
  }

  .motion-item:hover .motion-copy {
    opacity: 1;
    transform: translateY(0);
  }
}

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

body.chat-open {
  overflow: hidden;
}

.chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 20;
  padding: 0.68rem 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  color: #111;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0.5rem 1.8rem rgba(0, 0, 0, 0.11);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.chat-launcher:hover {
  background: #f4f4f4;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(5px);
}

.chat-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 31;
  display: flex;
  width: min(25rem, calc(100vw - 2rem));
  height: min(40rem, calc(100vh - 2rem));
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.13);
  border-radius: 0.8rem;
  background: #fff;
  box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.16);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  animation: chat-in 180ms ease-out;
}

.chat-panel[hidden],
.chat-backdrop[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.1rem;
  border-bottom: 1px solid #ededed;
}

.chat-header p {
  margin: 0 0 0.25rem;
  color: rgba(0, 0, 0, 0.4);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

.chat-header h2 {
  margin: 0;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015rem;
}

.chat-close {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  border: 1px solid #ededed;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-log {
  display: flex;
  min-height: 0;
  padding: 1.15rem;
  overflow-y: auto;
  flex: 1;
  flex-direction: column;
  gap: 0.8rem;
  overscroll-behavior: contain;
}

.chat-message {
  max-width: 90%;
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  white-space: pre-line;
}

.chat-message--assistant {
  align-self: flex-start;
  border: 1px solid #ededed;
  border-bottom-left-radius: 0.15rem;
  background: #fafafa;
}

.chat-message--user {
  align-self: flex-end;
  border-bottom-right-radius: 0.15rem;
  color: #fff;
  background: #111;
}

.chat-result {
  display: block;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid #e9e9e9;
  color: inherit;
}

.chat-result strong,
.chat-result span,
.chat-result small {
  display: block;
}

.chat-sources {
  display: flex;
  margin-top: 0.65rem;
  padding-top: 0.6rem;
  border-top: 1px solid #e9e9e9;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chat-source {
  display: block;
  max-width: 100%;
  padding: 0.34rem 0.55rem;
  overflow: hidden;
  border: 1px solid #e1e1e1;
  border-radius: 999px;
  color: rgba(0, 0, 0, 0.66);
  background: #fff;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-source:hover {
  border-color: rgba(0, 0, 0, 0.45);
  color: #111;
}

.chat-message--pending {
  color: rgba(0, 0, 0, 0.48);
}

.chat-form button:disabled,
.chat-form input:disabled {
  cursor: wait;
  opacity: 0.45;
}

.chat-result strong {
  margin-bottom: 0.15rem;
  color: #111;
  font-size: 0.75rem;
}

.chat-result span {
  color: rgba(0, 0, 0, 0.62);
  font-size: 0.69rem;
  line-height: 1.4;
}

.chat-result small {
  margin-top: 0.28rem;
  color: rgb(255, 0, 170);
  font-size: 0.6rem;
}

.chat-suggestions {
  display: flex;
  padding: 0 1.15rem 0.8rem;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-suggestions::-webkit-scrollbar {
  display: none;
}

.chat-suggestions button {
  flex: 0 0 auto;
  padding: 0.5rem 0.72rem;
  border: 1px solid #e6e6e6;
  border-radius: 999px;
  background: #fff;
  font-size: 0.75rem;
  cursor: pointer;
}

.chat-suggestions button:hover {
  border-color: rgba(0, 0, 0, 0.45);
}

.chat-form {
  display: grid;
  min-height: 3.5rem;
  grid-template-columns: 1fr 2.4rem;
  align-items: center;
  gap: 0.5rem;
  margin: 0 1.15rem;
  padding: 0.5rem 0.55rem 0.5rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 1.35rem;
}

.chat-form:focus-within {
  border-color: #111;
}

.chat-form input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
}

.chat-form button {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #111;
  cursor: pointer;
}

.chat-privacy {
  margin: 0.65rem 1rem 0.8rem;
  color: rgba(0, 0, 0, 0.38);
  font-size: 0.6875rem;
  text-align: center;
}

@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@media screen and (max-width: 768px) {
  .motion-showcase {
    height: 18rem;
  }

}

@media screen and (max-width: 480px) {
  .motion-showcase {
    grid-template-columns: minmax(7rem, 0.85fr) minmax(0, 1.15fr);
    height: 16.5rem;
  }

  .motion-copy {
    padding: 0.8rem;
    font-size: 0.75rem;
  }

  .chat-panel {
    inset: auto 0 0;
    width: 100%;
    height: min(86vh, 42rem);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0.8rem 0.8rem 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .motion-item video,
  .motion-item img,
  .chat-panel {
    animation: none;
    transition: none;
  }
}
