.message-viewport {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  padding: 20px 15px 18px;
  background:
    radial-gradient(circle at 10% 12%, rgba(0,0,0,.026) 0 2px, transparent 2.5px),
    radial-gradient(circle at 88% 24%, rgba(0,0,0,.022) 0 1.5px, transparent 2px),
    linear-gradient(#fff, #fff);
  background-size: 96px 96px, 132px 132px, auto;
}
.message-viewport::-webkit-scrollbar { width: 4px; }
.message-viewport::-webkit-scrollbar-thumb { background: #e5e5e5; border-radius: 99px; }
.message-list { display: grid; gap: 10px; }

.message-row { display: flex; flex-direction: column; max-width: 84%; }
.message-row.them { justify-self: start; align-items: flex-start; }
.message-row.me { justify-self: end; align-items: flex-end; }
.message-bubble {
  padding: 10px 13px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: -.005em;
  color: #111;
}
.message-row.them .message-bubble {
  background: #f3f3f3;
  border: 1px solid #f0f0f0;
  border-bottom-left-radius: 7px;
}
.message-row.me .message-bubble {
  background: #fff;
  border: 1px solid #111;
  border-bottom-right-radius: 7px;
}
.message-time { margin-top: 4px; padding: 0 4px; color: #aaa; font-size: 9px; }

.typing {
  width: fit-content;
  margin-top: 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 11px 13px;
  border-radius: 17px 17px 17px 7px;
  background: #f3f3f3;
  border: 1px solid #ededed;
}
.typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #888;
  animation: typing 1.05s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .14s; }
.typing span:nth-child(3) { animation-delay: .28s; }
@keyframes typing { 0%, 70%, 100% { opacity: .35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

.composer-wrap {
  position: relative;
  z-index: 20;
  padding: 10px 12px 0;
  border-top: 1px solid #e9e9e9;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(18px);
}
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: end;
  gap: 7px;
  border: 1px solid #d9d9d9;
  background: #fff;
  border-radius: 20px;
  padding: 5px 5px 5px 13px;
}
.composer textarea {
  resize: none;
  max-height: 128px;
  min-height: 34px;
  padding: 7px 0 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  font-size: 14px;
  line-height: 1.45;
}
.composer textarea::placeholder { color: #aaa; }
.composer-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: .15s ease;
}
.composer-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.reply-button { border: 1px solid #111; background: #111; color: #fff; }
.reply-button.is-loading svg { animation: replySpin .9s linear infinite; }
@keyframes replySpin { to { transform: rotate(360deg); } }
.composer-button:disabled { opacity: .28; cursor: default; }
.composer-button:not(:disabled):active { transform: scale(.96); }
.safe-bottom { height: max(9px, env(safe-area-inset-bottom)); }


@media (max-width: 390px) {
  .composer { grid-template-columns: minmax(0,1fr) 36px; }
}


.empty-state {
  min-height: min(44vh, 360px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  color: #222;
  padding: 36px 24px 24px;
}
.empty-state strong { font-size: 15px; letter-spacing: -.02em; }
.empty-state small { max-width: 310px; color: #999; font-size: 10px; line-height: 1.65; }
.empty-orbit {
  position: relative;
  width: 68px;
  height: 68px;
  margin-bottom: 7px;
  display: grid;
  place-items: center;
  border: 1px dashed #d8d8d8;
  border-radius: 50%;
}
.empty-orbit::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid #efefef;
  border-radius: 50%;
}
.empty-orbit span { position: relative; z-index: 1; font-size: 20px; color: #222; }
.empty-orbit i { position: absolute; top: 4px; right: 11px; width: 5px; height: 5px; border-radius: 50%; background: #111; box-shadow: -48px 40px 0 #dedede; }
.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 10px 0;
  color: #b1b1b1;
  font-size: 7px;
  font-weight: 750;
  letter-spacing: .11em;
}

/* v5 message controls */
.message-meta-row {
  min-height: 20px;
  margin-top: 2px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.message-row.me .message-meta-row { flex-direction: row-reverse; }
.message-meta-row .message-time { margin: 0; padding: 0 2px; }
.message-menu-button {
  width: 28px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b7b7b7;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 1px;
  cursor: pointer;
}
.message-menu-button:hover { background: #f4f4f4; color: #555; }
.message-menu-button:active { transform: scale(.96); }
