#comments-popup {
  display: none;
  position: absolute;
  right: 2em;
  /* top: 10em; */
  z-index: 1000;
  width: 420px;
  min-width: 200px;
  min-height: 200px;
  transition: all 0.2s;
}

#comments-popup .resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -5px;
  z-index: 1001;
}

#comments-popup .resize-handle-left {
  left: -5px;
  cursor: nwse-resize;
}

#comments-popup .resize-handle-right {
  right: -5px;
  cursor: nesw-resize;
}

#comments-list {
  margin-top: 0.5em;
    overflow-y: auto;
    height: 380px;
    /* align to vertical bottom */
    display: flex;
    flex-direction: column-reverse;
}

#new-comment-form {
    margin-top: auto;
}

#new-comment-form textarea {
  width: 94%;
  resize: vertical;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  padding: 0.5em;
  font-size: 16px; /* Prevent iOS zoom on focus */
}

#new-comment-form button[type="submit"] {
  margin-top: 0.5em;
  float: right;
}

.comment-item {
    border-top: 1px solid var(--color-border);
    padding: 0.5em 0 1.5em 0;
    position: relative;
}

.comment-item.last-read {
    border-bottom: 2px solid var(--color-border);
}

.comment-content {
    margin-top:0.2em;
}

.comment-action-container {
    position: absolute;
    bottom: 0.2em;
    right: 0.2em;
    display: flex;
    gap: 0.2em;
}

.delete-comment-btn,
.edit-comment-btn {
    border: none;
    background: none;
    font-weight: bold;
    cursor: pointer;
}

.send-icon {
    width: 28px;
    height: 28px;
    color: var(--color-text);
}

@media (max-width: 600px) {
    #comments-popup {
        position: fixed;
        right: 0;
        left: 0;
        top: auto;
        bottom: env(keyboard-inset-height, 0);
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 0.5em;
        border-radius: 10px 10px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s;
    }

    #comments-popup.open {
        transform: translateY(0);
    }
}

.comment-item.highlight-flash {
    animation: comment-flash 2s ease-out;
}

@keyframes comment-flash {
    from { background: #ffff99; }
    to { background: transparent; }
}

#comment-participants {
  margin-bottom: 0.3em;
}

.comment-presence-avatar {
  margin-right: 0.2em;
}

.comment-presence-avatar.inactive {
  opacity: 0.4;
  filter: grayscale(1);
}
.comment-presence-avatar.inactive + .avatar-initial {
  opacity: 0.4;
  filter: grayscale(1);
}
