:root {
  --paper: #ffffff;
  --ink: #292b28;
  --mute: #62655e;
  --faint: #b7b7b1;
  --line: #ececea;
  --underline: #bfc4b8;
  --chip: #f3f3f1;
  --mark: #f8b99d;
  --mark-ink: #35251e;
  --sans: Geist, Inter, "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--mark);
  color: var(--mark-ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

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

.shell {
  width: min(680px, calc(100% - 48px));
  height: calc(100dvh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 28px 18px;
}

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--chip);
  display: block;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;
  display: block;
}

.bar h1 {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.name {
  display: block;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.role {
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--mute);
}

.role.is-typing::after {
  content: "...";
  display: inline-block;
  width: 1.15em;
  text-align: left;
  animation: ellipsis 1.2s steps(4, end) infinite;
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 28px 32px;
}

.msg {
  max-width: min(440px, 88%);
  animation: rise 0.55s var(--ease) both;
}

.msg.preload {
  display: none;
}

.msg h2,
.msg p {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--ink);
}

.msg.user {
  align-self: flex-end;
}

.msg.user h2,
.msg.user p {
  background: var(--chip);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
}

.msg.assistant {
  align-self: flex-start;
}

.msg a {
  text-decoration: underline;
  text-decoration-color: var(--underline);
  text-underline-offset: 3px;
}

.msg a:hover {
  text-decoration-color: var(--ink);
}

mark {
  background: var(--mark);
  color: var(--mark-ink);
  border-radius: 5px;
  padding: 1px 4px 2px;
}

mark a {
  text-decoration-color: var(--mark-ink);
}

.caret {
  display: inline-block;
  width: 1px;
  height: 1.05em;
  background: var(--ink);
  vertical-align: text-bottom;
  animation: blink 1.05s steps(1) infinite;
}

.avatar:focus-visible,
.name:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.foot {
  padding: 8px 28px 22px;
}

.capsule {
  position: relative;
  height: 56px;
  border-radius: 999px;
  background: var(--chip);
  overflow: hidden;
}

.crawl {
  position: absolute;
  inset: 0;
  transform: translateX(-72px);
  animation: crawl 12s linear infinite;
  pointer-events: none;
}

.snail {
  position: absolute;
  top: 8px;
  left: 0;
  color: var(--ink);
}

.snail svg {
  display: block;
  animation: bob 0.7s ease-in-out infinite;
}

.feelers {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: nod 1s ease-in-out infinite;
}

@keyframes crawl {
  from {
    transform: translateX(-72px);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1.5px);
  }
}

@keyframes nod {
  0%,
  100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes ellipsis {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

@media (max-width: 640px) {
  body {
    display: block;
  }

  .shell {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .bar,
  .log,
  .foot {
    padding-left: 20px;
    padding-right: 20px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .msg {
    animation: none;
  }

  .crawl {
    animation: none;
    transform: translateX(12px);
  }

  .snail svg,
  .feelers {
    animation: none;
  }

  .caret {
    animation: none;
  }

  .role.is-typing::after {
    animation: none;
    content: "...";
  }
}
