* {
  box-sizing: border-box;
}

/* Base layout */
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #000;
  color: #fff;
}

#comment-app {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;

  /* NEW – full mobile responsive layout */
  min-height: 100vh;        /* makes app fill the screen */
  display: flex;            /* enables flexbox */
  flex-direction: column;   /* stack top → bottom */
}


/* Header */
.comment-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  background: none;
  border: none;
  color: #8ab4ff;
  font-size: 0.95rem;
  cursor: pointer;
}

.chapter-title {
  font-weight: 600;
}

.comment-count-badge {
  margin-left: auto;
  background: #1f2933;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Heading + toolbar */
.comments-heading {
  margin-top: 16px;
  margin-bottom: 8px;
}

.comment-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.comment-toolbar select {
  background: #111827;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Comments list – match the HTML id="commentsList" */
#commentsList {
  flex: 1;              /* takes all remaining vertical space */
  overflow-y: auto;
  padding-bottom: 12px; /* space above input bar */
}


.comment-card {
  background: #151515;
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 0 0 1px #222;
}

/* Top row: name + time + trash */
.comment-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.comment-meta {
  background: #111;
  border-radius: 4px;
  padding: 4px 8px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.comment-name {
  font-weight: 600;
}

.comment-time {
  font-size: 0.75rem;
  opacity: 0.7;
}

.comment-top-actions button {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
}

/* Comment body */
.comment-body {
  margin-top: 6px;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Bottom row: edit / reply / react */
.comment-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.comment-bottom-left button,
.comment-bottom-right button {
  background: #1f2933;
  border: none;
  color: #e5e7eb;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 6px;
}

/* Reactions row */
.comment-reactions {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.reaction-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.reaction-chip {
  background: #1f2933;
  border-radius: 999px;
  padding: 2px 6px;
}

.reaction-picker {
  display: none;
  gap: 4px;
}

.reaction-picker.open {
  display: flex;
}

.reaction-picker button {
  background: #111827;
  border: none;
  border-radius: 4px;
  padding: 2px 4px;
  cursor: pointer;
}

/* Replies */
.reply-editor {
  margin-top: 8px;
}

.reply-input {
  width: 100%;
  min-height: 60px;
  background: #0b0b0b;
  color: #fff;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 6px 8px;
  resize: vertical;
}

.send-reply {
  margin-top: 4px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.replies {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reply-card {
  background: #101010;
  border-radius: 4px;
  padding: 6px 8px;
}

/* New top row for replies */
.reply-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.reply-actions {
  display: flex;
  gap: 6px;
}

.reply-actions button {
  background: #1f2933;
  border: none;
  color: #e5e7eb;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
}


.reply-meta {
  background: #111;
  border-radius: 4px;
  padding: 2px 6px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 0.8rem;
}

.reply-name {
  font-weight: 500;
}

.reply-time {
  opacity: 0.7;
  font-size: 0.7rem;
}

.reply-text {
  margin-top: 4px;
  font-size: 0.9rem;
}

/* New comment box */
.new-comment-card {
  background: #111;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 0 0 1px #222;
  display: flex;
  flex-direction: column;
  gap: 8px;

  /* optional but nice: keep it off the absolute bottom edge a bit */
  margin-top: 8px;
}

.name-input {
  width: 100%;
  background: #000;
  color: #fff;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 6px 8px;
}

#commentInput {
  width: 100%;
  min-height: 80px;
  background: #000;
  color: #fff;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 6px 8px;
  resize: vertical;
}

/* New input area wrapper */
.comment-input-area {
  background: #111;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 0 0 1px #222;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}


.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;           /* space BETWEEN emojis */
  margin-top: 12px;    /* space ABOVE emojis */
  margin-bottom: 12px; /* space BELOW emojis */
  padding: 6px 0;      /* optional internal breathing room */
}


.emoji-picker button {
  background: #000;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
}

.post-btn {
  background: #4f46e5;
  border: none;
  color: #fff;
  border-radius: 999px;
  padding: 8px 0;
  font-weight: 600;
  cursor: pointer;
}

/* Helpers */
.loading,
.no-comments {
  text-align: center;
  opacity: 0.7;
  font-size: 0.9rem;
}

/* Mobile */
@media (max-width: 600px) {
  #comment-app {
    padding: 12px;
  }

  .comment-card {
    padding: 8px 10px;
  }

  .new-comment-card {
    padding: 8px 10px;
  }
}
