.tk-chat {
  position: relative;
  border-radius: 18px;
  background: var(--paper-2);
}

.tk-chat::before {
  content: "";
  position: absolute;
  top: 0;
  right: 14px;
  left: 0;
  z-index: 2;
  height: 32px;
  border-radius: 18px 0 0;
  background: linear-gradient(var(--paper-2), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.tk-chat.is-cut::before {
  opacity: 1;
}

.tk-scroll {
  position: relative;
  max-height: min(64vh, 620px);
  min-height: 220px;
  overflow-y: auto;
  padding: 16px 6px 18px 16px;
  border-radius: 18px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.tk-scroll::-webkit-scrollbar {
  width: 14px;
}

.tk-field textarea::-webkit-scrollbar {
  width: 10px;
}

.tk-scroll::-webkit-scrollbar-track,
.tk-field textarea::-webkit-scrollbar-track {
  margin: 8px 0;
  background: transparent;
}

.tk-scroll::-webkit-scrollbar-thumb,
.tk-field textarea::-webkit-scrollbar-thumb {
  border: 4px solid transparent;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.22);
  background-clip: content-box;
}

.tk-field textarea::-webkit-scrollbar-thumb {
  border-width: 3px;
}

.tk-scroll::-webkit-scrollbar-thumb:hover,
.tk-field textarea::-webkit-scrollbar-thumb:hover {
  background-color: rgba(17, 17, 17, 0.42);
}

.tk-scroll::-webkit-scrollbar-button,
.tk-field textarea::-webkit-scrollbar-button {
  display: none;
}

@supports not selector(::-webkit-scrollbar) {
  .tk-scroll,
  .tk-field textarea {
    scrollbar-width: thin;
    scrollbar-color: rgba(17, 17, 17, 0.22) transparent;
  }
}

.tk-scroll:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.tk-thread {
  display: grid;
  gap: 10px;
}

.tk-day,
.tk-event,
.tk-new {
  display: flex;
  justify-content: center;
  font-size: 12px;
  line-height: 1.4;
}

.tk-day {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 4px 0;
  transition: opacity 0.2s ease;
}

.tk-day.is-stuck {
  opacity: 0;
}

.tk-day span {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(17, 17, 17, 0.08);
  font-weight: 600;
}

.tk-event span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
}

.tk-event i {
  font-size: 14px;
}

.tk-new {
  align-items: center;
  gap: 12px;
  margin: 4px 0;
  font-weight: 600;
  color: var(--red-text);
}

.tk-new::before,
.tk-new::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(224, 16, 61, 0.3);
}

.tk-msg {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: min(82%, 600px);
}

.tk-msg.is-me {
  justify-self: end;
}

.tk-msg.is-staff {
  max-width: min(calc(82% + 40px), 640px);
}

.tk-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tk-msg.is-staff .tk-avatar,
.tk-avatar.is-staff {
  background: rgba(224, 16, 61, 0.1);
  box-shadow: none;
  color: var(--red-text);
}

.tk-avatar.is-me {
  background: var(--ink);
  box-shadow: none;
  color: var(--paper);
}

.tk-bubble {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 10px 14px 8px;
  border-radius: 6px 18px 18px 18px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(17, 17, 17, 0.06);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.tk-msg.is-me .tk-bubble {
  border-radius: 18px 6px 18px 18px;
  background: var(--ink);
  box-shadow: none;
  color: var(--paper);
}

.tk-bubble [data-text] {
  white-space: pre-line;
}

.tk-who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 13px;
}

.tk-who b {
  font-weight: 600;
}

.tk-who small {
  font-size: 12px;
  color: var(--ink-2);
}

.tk-who .pn-tag {
  margin-left: 0;
}

.tk-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.tk-msg.is-me .tk-meta {
  color: rgba(255, 255, 255, 0.72);
}

.tk-meta i {
  font-size: 15px;
}

.tk-meta .ph-checks {
  color: #ffffff;
}

.tk-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tk-docs[hidden] {
  display: none;
}

.tk-doc {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--paper-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  color: var(--ink);
}

.tk-msg.is-me .tk-doc {
  background: rgba(255, 255, 255, 0.14);
  color: var(--paper);
}

.tk-doc > i {
  flex: none;
  font-size: 17px;
}

.tk-doc span {
  display: grid;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tk-doc small {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
}

button.tk-doc {
  transition: scale 0.15s var(--ease);
}

button.tk-doc:active {
  scale: 0.97;
}

.tk-down {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 14px rgba(17, 17, 17, 0.16), 0 0 0 1px rgba(17, 17, 17, 0.06);
  font-size: 18px;
  transition: scale 0.15s var(--ease);
}

.tk-down[hidden] {
  display: none;
}

.tk-down:active {
  scale: 0.94;
}

.tk-compose {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tk-compose[hidden] {
  display: none;
}

.tk-compose .row {
  margin: 0;
}

.tk-box {
  display: grid;
  gap: 6px;
  padding: 12px 10px 8px 16px;
  border-radius: 20px;
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1.5px transparent;
  cursor: text;
  transition: box-shadow 0.2s ease;
}

.tk-box:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--focus);
}

.row.is-error .tk-box {
  box-shadow: inset 0 0 0 1.5px var(--red);
}

.tk-compose .tk-field {
  display: block;
}

.tk-compose .tk-box .tk-field textarea,
.tk-compose .tk-box .tk-field textarea:is(:hover, :focus, :focus-visible) {
  height: 24px;
  min-height: 24px;
  max-height: 168px;
  padding: 0 4px 0 0;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: none;
  box-shadow: none;
  font-size: 15px;
  line-height: 24px;
  resize: none;
}

.tk-compose .tk-field > span,
.tk-compose .tk-field:focus-within > span {
  position: absolute;
  top: 0;
  right: 6px;
  left: 0;
  min-height: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 24px;
  color: var(--ink-2);
  white-space: nowrap;
  transform: none;
  transition: opacity 0.15s ease;
}

.tk-compose .tk-box .tk-field > span::after {
  content: none;
}

.tk-compose .tk-field.is-filled > span {
  opacity: 0;
  transform: none;
}

.tk-box-foot {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  margin-left: -8px;
}

.tk-attach,
.tk-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 19px;
  cursor: pointer;
  transition: background-color 0.2s ease, scale 0.15s var(--ease);
}

.tk-send {
  grid-column: 3;
  background: var(--red);
  color: #ffffff;
}

.tk-attach:active,
.tk-send:active {
  scale: 0.94;
}

.tk-attach:focus-within {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.tk-picked li {
  background: var(--paper);
}

.tk-box-foot .field-msg {
  grid-column: 1 / -1;
  margin-top: 0;
}

.tk-box-foot .field-msg:empty {
  display: none;
}

.tk-compose-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.tk-compose-foot .pn-meta b {
  font-weight: 600;
  color: var(--ink);
}

.tk-people li {
  align-items: center;
}

.tk-people .tk-avatar {
  width: 36px;
  height: 36px;
}

@media (hover: hover) and (pointer: fine) {
  .tk-attach:hover {
    background: rgba(17, 17, 17, 0.08);
  }

  .tk-send:hover {
    background: var(--ink);
  }

  .tk-down:hover {
    background: var(--paper-2);
  }
}

@media (max-width: 640px) {
  .tk-scroll {
    max-height: 62vh;
    padding: 12px 2px 14px 10px;
  }

  .tk-msg {
    max-width: 92%;
  }

  .tk-msg.is-staff {
    max-width: min(100%, calc(92% + 36px));
  }

  .tk-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
}
