.pg {
  padding-top: clamp(130px, 20vh, 190px);
}

.cs-kicker a {
  color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color 0.2s ease;
}

.cs-kicker a:hover {
  color: var(--ink);
}

.pg-title {
  margin-top: 24px;
  width: fit-content;
  font-size: clamp(52px, 8.5vw, 120px);
  line-height: 0.92;
  letter-spacing: -0.06em;
  font-weight: 450;
}

.pg-lede {
  margin-top: 28px;
  max-width: 34rem;
  font-size: clamp(17px, 1.5vw, 19px);
  color: var(--ink-2);
}

.pg-more {
  margin-top: 20px;
  color: var(--ink-3);
}

.pg-more a {
  color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color 0.2s ease;
}

.pg-more a:hover {
  color: var(--ink);
}

.ff {
  --r: 20px;
  display: block;
  max-width: 40rem;
  margin-top: 24px;
  padding: 14px 18px;
  background: var(--surface);
  font-size: 14px;
  color: var(--ink-2);
}

/* model tiles */

.pg-models {
  margin-top: 56px;
}

.models {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.model {
  --r: 26px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  padding: 20px 20px 32px;
  text-align: left;
  background: var(--surface);
  color: var(--ink-2);
  transition: background-color 0.35s ease, color 0.35s ease, transform 0.6s var(--ease);
}

.model:hover {
  background: var(--surface-2);
}

.model:active {
  transform: scale(0.98);
}

.model .m-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.model .name {
  font-size: 24px;
  letter-spacing: -0.04em;
  color: var(--ink);
  transition: color 0.35s ease;
}

.model .state {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.model .what {
  font-size: 15px;
  line-height: 1.45;
}

.model .bar {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 14px;
  height: 3px;
  border-radius: 3px;
  background: transparent;
  overflow: hidden;
}

.model .bar b {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: currentColor;
  transition: width 0.3s linear, opacity 0.6s ease 0.6s;
}

.model.on {
  background: var(--ink);
  color: #a9a9a9;
}

.model.on .name {
  color: #fff;
}

.model.on .state {
  color: #8a8a8a;
}

.model.on .bar {
  background: #2a2a2a;
  color: #fff;
}

.model.on:not(.loading) .bar,
.model.on:not(.loading) .bar b {
  background: transparent;
  opacity: 0;
}

.model.loading .bar b {
  min-width: 6%;
}

.model.failed .state {
  color: var(--accent);
}

@media (max-width: 900px) {
  .models {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model {
    min-height: 128px;
  }
}

/* the conversation */

.chat-panel {
  --r: 36px;
  margin-top: 16px;
  padding: clamp(20px, 3vw, 32px);
  background: var(--surface);
}

.chat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.chat-name {
  font-size: 15px;
  color: var(--ink-3);
}

.stats {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 20px;
}

.log:empty {
  display: none;
}

.msg {
  max-width: min(80%, 40rem);
  padding: 10px 16px;
  border-radius: 20px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.5;
}

.msg.you {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bg);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.story {
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

.story b {
  color: var(--ink);
  font-weight: 500;
}

.typing::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--ink);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.suggest {
  margin-top: 20px;
  font-size: 14px;
  color: var(--ink-3);
}

.suggest a {
  color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
}

.suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.suggest-row .btn {
  height: auto;
  min-height: 36px;
  padding: 8px 16px;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
  background: var(--bg);
  box-shadow: none;
}

.suggest-row .btn:hover {
  background: #fafafa;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding: 6px 6px 6px 20px;
  border-radius: 28px;
  background: var(--bg);
  transition: box-shadow 0.3s ease;
}

.composer:focus-within {
  box-shadow: inset 0 0 0 1px var(--ink-3);
}

textarea {
  flex: 1;
  min-width: 0;
  align-self: center;
  padding: 10px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 24px;
  max-height: 200px;
  overflow-y: hidden;
}

textarea::placeholder {
  color: var(--ink-3);
}

/* the whole composer shows focus, so the textarea itself doesn't need a ring */
textarea:focus,
textarea:focus-visible {
  outline: none;
}

.composer .btn {
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.note {
  margin-top: 40px;
  max-width: 36rem;
  font-size: 14px;
  color: var(--ink-3);
}

.note a {
  color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
}

/* a neural net with no libraries */

.pg-demo {
  padding-top: clamp(96px, 16vh, 180px);
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}

.demo-copy .soft {
  margin-top: 18px;
  max-width: 30rem;
  font-size: 17px;
  line-height: 1.6;
}

.demo-copy .row {
  margin-top: 24px;
}

.digits {
  --r: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 20px 24px;
  padding: clamp(18px, 2.6vw, 28px);
  background: var(--surface);
}

.pad {
  position: relative;
  aspect-ratio: 1;
  border-radius: 22px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.pad canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.pad p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-4);
  font-size: 15px;
  pointer-events: none;
}

.digits-side {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.guess span {
  display: block;
  font-size: 13px;
  color: var(--ink-3);
}

.guess b {
  display: block;
  font-size: 88px;
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
}

.seen canvas {
  width: 112px;
  height: 112px;
  border-radius: 10px;
  background: var(--bg);
  image-rendering: pixelated;
  box-shadow: inset 0 0 0 1px var(--line);
}

.seen .cap,
.hidden .cap {
  display: block;
  margin-top: 8px;
  color: var(--ink-3);
}

.hidden > div {
  display: grid;
  grid-template-columns: repeat(8, 12px);
  gap: 5px;
}

.hidden i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.08;
  transition: opacity 0.2s ease;
}

.outs {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.outs li {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.outs b {
  display: block;
  width: 100%;
  max-width: 24px;
  height: 56px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, #c9c9c6 calc(var(--v) * 100%), transparent 0);
  box-shadow: inset 0 -1px 0 var(--line);
  transition: background 0.2s ease;
}

.outs li.top {
  color: var(--ink);
}

.outs li.top b {
  background: linear-gradient(to top, var(--ink) calc(var(--v) * 100%), transparent 0);
}

.digits-btns {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.digits-btns .btn {
  background: var(--bg);
}

/* the tokenizer */

.reads-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
}

/* the heading comes first for screen readers, the card still sits on the left */
.reads-card {
  order: -1;
}

.reads-card {
  --r: 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: clamp(18px, 2.6vw, 28px);
  background: var(--surface);
}

.tok-in {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  font-size: clamp(18px, 1.7vw, 22px);
  line-height: 1.4;
  letter-spacing: -0.02em;
  resize: none;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.tok-in:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--ink-3);
}

.tok-out {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px 3px;
  min-height: 112px;
}

.tk {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.tk b {
  padding: 3px 6px;
  border-radius: 7px;
  transition: box-shadow 0.15s ease;
  background: var(--bg);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.35;
  white-space: pre;
  color: var(--ink);
}

.tk.cut b {
  background: #ffe2d4;
}

.tk.same b {
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.tk.same i {
  color: var(--ink);
}

.tk i {
  margin-top: 3px;
  padding-left: 6px;
  font-style: normal;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.tk.new {
  animation: tk-in 0.35s var(--ease) both;
  animation-delay: calc(var(--k, 0) * 22ms);
}

@keyframes tk-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.tok-stats {
  color: var(--ink-3);
}

.tok-try {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tok-try .btn {
  background: var(--bg);
}

@media (max-width: 900px) {
  .demo-grid,
  .reads-grid {
    grid-template-columns: 1fr;
  }

  .reads-card {
    order: 0;
  }
}

@media (max-width: 520px) {
  .digits {
    grid-template-columns: 1fr;
  }

  .digits-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 18px;
  }

  .guess b {
    font-size: 64px;
  }

  .seen canvas {
    width: 84px;
    height: 84px;
  }

  .hidden > div {
    grid-template-columns: repeat(8, 9px);
    gap: 4px;
  }

  .hidden i {
    width: 9px;
    height: 9px;
  }
}

/* the digit pad and the tokenizer need javascript to do anything */
html:not(.js) .digits,
html:not(.js) .reads-card {
  display: none;
}

/* used by the script when messages show up */

.fade-in {
  animation: fade-up 0.5s var(--ease) both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .typing::after {
    animation: none;
  }
}
