
.chat-panel {
  position: relative;
  display: flex;
  height: clamp(420px, 68vh, 640px);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.chat-head {
  flex: none;
}

.chat-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #14f195);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #14f195) 60%, transparent);
  animation: chat-live-pulse 2s ease-out infinite;
}

@keyframes chat-live-pulse {
  70% {
    box-shadow: 0 0 0 6px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

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

.chat-scroll {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 10px 4px;
  scroll-behavior: auto;
}

.chat-empty {
  margin: 24px 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.chat-day {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.chat-day span {
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 9%, transparent);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 10px;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 2px;
}

.chat-row.is-first {
  margin-top: 8px;
}

.chat-row.is-own {
  justify-content: flex-end;
}

.chat-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-raised, var(--surface));
  object-fit: cover;
}

.chat-avatar-gap {
  flex: none;
  width: 30px;
}

.chat-bubble {
  position: relative;
  min-width: 0;
  max-width: min(86%, 300px);
  border-radius: 14px 14px 14px 4px;
  background: var(--surface-raised, var(--surface));
  padding: 6px 9px 4px;
}

.chat-row.is-first .chat-bubble {
  border-top-left-radius: 14px;
}

.chat-row.is-own .chat-bubble {
  border-radius: 14px 14px 4px 14px;
  background: color-mix(in srgb, var(--accent, #14f195) 20%, var(--surface));
}

.chat-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  margin-bottom: 1px;
}

.chat-author {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-cyan, #22d3ee);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-author:hover {
  text-decoration: underline;
}

.chat-name .comment-follow-button {
  width: 20px;
  height: 20px;
  margin-left: 0;
}

.chat-name .comment-follow-button svg {
  width: 13px;
  height: 13px;
}

.chat-quote {
  display: block;
  margin: 2px 0 4px;
  border: 0;
  border-left: 3px solid var(--accent, #14f195);
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent, #14f195) 10%, transparent);
  color: inherit;
  cursor: pointer;
  font: inherit;
  max-width: 100%;
  padding: 3px 7px;
  text-align: left;
}

.chat-quote b {
  display: block;
  overflow: hidden;
  color: var(--accent, #14f195);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-quote span {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-text {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-text a.post-link {
  color: var(--accent-cyan, #22d3ee);
}

.chat-coin {
  display: inline-block;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent, #14f195) 16%, transparent);
  color: var(--accent, #14f195);
  font-weight: 800;
  padding: 0 5px;
  text-decoration: none;
}

.chat-coin:hover {
  text-decoration: underline;
}

.chat-media {
  width: auto;
  height: auto;
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 3px 0 2px;
  border-radius: 10px;
  cursor: zoom-in;
  object-fit: cover;
}

video.chat-media {
  cursor: default;
  background: #000;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 10.5px;
}

.chat-actions {
  display: none;
  gap: 2px;
}

.chat-row:hover .chat-actions,
.chat-row:focus-within .chat-actions {
  display: inline-flex;
}

.chat-actions button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.chat-actions button:hover {
  background: color-mix(in srgb, var(--text) 12%, transparent);
  color: var(--text);
}

.chat-actions svg,
.chat-composer svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: none) {
  .chat-actions {
    display: inline-flex;
  }
}

.chat-jump {
  position: absolute;
  right: 12px;
  bottom: 74px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 12px;
}

.chat-jump[hidden],
.chat-reply-bar[hidden],
.chat-attach-bar[hidden],
.chat-emoji[hidden],
.chat-coins[hidden],
.chat-signin[hidden],
.chat-composer[hidden] {
  display: none;
}

.chat-reply-bar,
.chat-attach-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 5px 10px;
  font-size: 12px;
}

.chat-reply-bar div {
  min-width: 0;
  flex: 1;
  border-left: 3px solid var(--accent, #14f195);
  padding-left: 7px;
}

.chat-reply-bar b {
  display: block;
  color: var(--accent, #14f195);
  font-size: 11.5px;
}

.chat-reply-bar span,
.chat-attach-bar span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attach-bar span {
  flex: 1;
}

.chat-attach-bar img,
.chat-attach-bar video {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
}

.chat-reply-bar button,
.chat-attach-bar button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
}

.chat-composer button {
  display: grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}

.chat-composer button:hover {
  color: var(--text);
}

.chat-composer button svg {
  width: 20px;
  height: 20px;
}

.chat-composer .chat-send {
  background: var(--accent, #14f195);
  color: var(--on-accent, #04130c);
}

.chat-composer .chat-send:disabled {
  opacity: 0.45;
  cursor: default;
}

.chat-composer textarea {
  min-width: 0;
  flex: 1;
  max-height: 110px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-raised, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.3;
  padding: 8px 12px;
  resize: none;
}

.chat-composer textarea:focus {
  border-color: var(--accent, #14f195);
  outline: none;
}

.chat-signin {
  border-top: 1px solid var(--border);
  padding: 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
}

.chat-signin a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.chat-emoji,
.chat-coins {
  position: absolute;
  right: 8px;
  bottom: 56px;
  left: 8px;
  z-index: 5;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.45);
  padding: 6px;
}

.chat-emoji {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.chat-emoji button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1.5;
  padding: 0;
}

.chat-emoji button:hover {
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

.chat-coins button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  text-align: left;
}

.chat-coins button:hover,
.chat-coins button.is-active {
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

.chat-coins img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-coins small {
  color: var(--text-muted);
}
