html, body { overflow: hidden; }

/* Respect the HTML `hidden` attribute even when CSS sets an explicit display. */
[hidden] { display: none !important; }

.messages-body {
  background: #ffffff;
}

.messages-body .top-nav {
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(27, 58, 31, 0.18);
}

.messages-main {
  position: fixed;
  top: 58px; /* roughly the nav height */
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 2fr;
  background: #ffffff;
}

.conv-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #cfd4cf; /* grey divider between 1/3 and 2/3 */
  min-width: 0;
  background: #ffffff;
}

.conv-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #e7ebe7;
}
.conv-pane-header h2 {
  font-size: 1.15rem;
  color: #14301a;
  margin: 0;
}
.new-conv-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(46, 107, 53, 0.35);
  background: #fff;
  color: #14301a;
  cursor: pointer;
}
.new-conv-btn:hover {
  background: #eaf6d4;
  border-color: #2e6b35;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.conv-empty-note {
  padding: 16px;
  color: #6b7a6e;
  font-size: 0.92rem;
}

.conv-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: #14301a;
  margin-bottom: 2px;
}
.conv-item:hover { background: #f1f5ee; }
.conv-item.active { background: #e8f1df; }

.conv-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.conv-item-name {
  font-weight: 700;
  color: #14301a;
  font-size: 0.95rem;
}
.conv-item-time {
  font-size: 0.72rem;
  color: #6b7a6e;
}
.conv-item-preview {
  font-size: 0.85rem;
  color: #4a5e4f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Without min-height: 0 a grid item grows to fit content, which makes the
     inner .message-scroll's overflow:auto never activate when there are more
     messages than the viewport can show. */
  min-height: 0;
  height: 100%;
  background: #ffffff;
}

.conv-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7a6e;
  text-align: center;
  padding: 20px;
}

.conv-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.conv-active-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e7ebe7;
}
.conv-active-header h3 {
  margin: 0;
  color: #14301a;
  font-size: 1.05rem;
}

.group-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  background: #fff7e0;
  border-bottom: 1px solid #f0dfa0;
  color: #5b4410;
  font-size: 0.88rem;
  line-height: 1.4;
}
.group-warning-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.conv-active-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.conv-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-rename-btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 2px 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #4a5e4f;
  cursor: pointer;
}
.conv-rename-btn:hover {
  background: rgba(46, 107, 53, 0.12);
  color: #14301a;
}

.conv-rename-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.conv-rename-row input {
  font: inherit;
  flex: 1 1 200px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(46, 107, 53, 0.3);
  background: #fff;
  color: #0f1a10;
}
.conv-rename-row input:focus {
  outline: none;
  border-color: #2e6b35;
  box-shadow: 0 0 0 3px rgba(46, 107, 53, 0.18);
}
.conv-rename-row .cta { margin-top: 0; padding: 7px 14px; font-size: 0.85rem; }

html.theme-dark .conv-rename-btn { color: #b8bdb8; }
html.theme-dark .conv-rename-btn:hover { background: rgba(212, 160, 23, 0.18); color: #ffe07a; }
html.theme-dark .conv-rename-row input {
  background: #0f1411;
  color: #eaeaea;
  border-color: #2f3531;
}

.conv-mod-toolbar {
  display: flex;
  gap: 6px;
}

.conv-mod-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(46, 107, 53, 0.35);
  background: #fff;
  color: #14301a;
  cursor: pointer;
}
.conv-mod-btn:hover {
  background: #eaf6d4;
  border-color: #2e6b35;
}
.conv-mod-btn.active {
  background: #a02020;
  color: #fff;
  border-color: #7a1818;
}

.conv-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.participant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef2ec;
  border: 1px solid #cfd4cf;
  font-size: 0.78rem;
  color: #14301a;
}

.participant-name {
  line-height: 1.2;
}

.participant-remove {
  background: rgba(0, 0, 0, 0.15);
  color: #14301a;
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.participant-remove:hover {
  background: #a02020;
  color: #fff;
}

.mute-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  background: #f3e7e7;
  border-bottom: 1px solid #e0c7c7;
  color: #5a1818;
  font-size: 0.88rem;
  line-height: 1.4;
}

.message-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-row {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}
.message-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}
.message-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.message-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #4a5e4f;
  margin-bottom: 3px;
  padding: 0 4px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  font-size: 0.98rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-row.mine .message-bubble {
  background: #2e6b35;
  color: #eaf6d4;
  border-bottom-right-radius: 4px;
}
.message-row.theirs .message-bubble {
  background: #eef2ec;
  color: #14301a;
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 0.68rem;
  color: #8a9690;
  margin-top: 3px;
  padding: 0 4px;
}

.conv-footer {
  border-top: 1px solid #e7ebe7;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fcfcfc;
}

.message-btn {
  align-self: flex-start;
  margin-top: 0;
}

.conv-delete-btn {
  align-self: flex-start;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(160, 32, 32, 0.45);
  background: rgba(160, 32, 32, 0.1);
  color: #7a1818;
  cursor: pointer;
}
.conv-delete-btn:hover {
  background: #a02020;
  color: #fff;
  border-color: #7a1818;
}

.conv-footer-note {
  color: #6b7a6e;
  font-size: 0.85rem;
  font-style: italic;
}

.compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.compose textarea {
  font: inherit;
  resize: vertical;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(46, 107, 53, 0.3);
  background: #fff;
  color: #0f1a10;
}
.compose textarea:focus {
  outline: none;
  border-color: #2e6b35;
  box-shadow: 0 0 0 3px rgba(46, 107, 53, 0.18);
}
.compose-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.compose-actions .cta { margin-top: 0; padding: 8px 16px; }

/* New-conversation dialog */
.msg-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 16, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.msg-dialog-backdrop[hidden] { display: none; }
.msg-dialog {
  background: #fff;
  border-radius: 16px;
  padding: 22px 22px 18px;
  width: min(420px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(46, 107, 53, 0.3);
}
.msg-dialog h3 {
  font-size: 1.1rem;
  color: #14301a;
  margin-bottom: 4px;
}
.msg-dialog-sub {
  font-size: 0.9rem;
  color: #4a5e4f;
  margin-bottom: 14px;
}
.msg-dialog-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #4a5e4f;
  margin-bottom: 6px;
}
#newConvSelect {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(46, 107, 53, 0.3);
  background: #fff;
  color: #0f1a10;
}
.msg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.msg-dialog-actions .cta { margin-top: 0; padding: 9px 16px; }

@media (max-width: 600px) {
  .messages-main { grid-template-columns: 1fr; }
  .conv-pane { border-right: none; border-bottom: 1px solid #cfd4cf; }
}
