/* ── Layout: main structure ── */
#main {
  flex: 1; padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
#chat-area {
  flex: 1; overflow: hidden; padding: 0;
  display: flex; flex-direction: column;
}
#chat-header { flex-shrink: 0; }
#chat-header-name { font-size: 14px; font-weight: bold; color: #d4d4d4; }
#chat-header-status { font-size: 11px; color: #555; }

#inbox {
  display: flex; flex-direction: column;
  flex: 1; align-items: stretch;
  padding: 16px 28px;
  overflow-y: auto;
  min-height: 0;
}
/* spacer pushes messages down */
#inbox-spacer { flex: 1; }

#send-area {
  padding: 16px 10px 20px 10px;
  border-top: 1px solid #333;
  background: #1e1e1e; flex-shrink: 0;
}
#send-area button { min-height: 36px; }
#send-area.hidden { display: none; }

#no-key-notice {
  padding: 10px 28px; font-size: 13px; color: #b8860b;
  border-top: 1px solid #333; background: #1e1e1e; flex-shrink: 0;
}

#payload {
  height: auto;
  min-height: 36px;
  max-height: 108px;
  line-height: 1.45;
  overflow-y: hidden;
  resize: none;
  box-sizing: border-box;
}

/* ── Sidebar ── */
#sidebar {
  width: 220px; min-width: 180px; background: #252526; border-right: 1px solid #333;
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto;
}
#sidebar h3 { color: #9cdcfe; margin: 0 0 12px; font-size: 14px; }
#contacts-title { display: flex; align-items: center; gap: 8px; margin: 7px 0 12px; }
#contacts-title h3 { margin: 0; }
#contacts-badge {
  display: none; background: #b8860b; color: #fff;
  font-size: 10px; border-radius: 10px; padding: 1px 6px; font-weight: bold;
}

#contact-list { flex: 1; overflow-y: auto; }
.contact-item {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 4px; cursor: pointer; font-size: 13px;
  color: #d4d4d4; border: 1px solid transparent; margin-bottom: 4px;
}
.contact-item:hover { background: #2d2d2d; border-color: #444; }
.contact-item.active { background: #264f78; border-color: #0e639c; color: #fff; }
.contact-addr { font-size: 10px; color: #666; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-unread {
  display: inline-block; background: #0e639c; color: #fff;
  font-size: 14px; font-weight: bold; border-radius: 10px;
  padding: 1px 6px; margin-left: 4px; vertical-align: middle;
}
.contact-item.active .contact-unread { background: #fff; color: #264f78; }
.contact-item.unknown { border-color: #5a4a00; background: #2a2200; }
.contact-item.unknown:hover { background: #332a00; }
.contact-item.unknown.active { background: #4a3800; border-color: #b8860b; }
.contact-badge-new { font-size: 9px; background: #b8860b; color: #fff; border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; }

.contact-actions {
  display: none; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  gap: 4px; align-items: center;
}
.contact-item:hover .contact-actions { display: flex; }
.contact-actions button { margin: 0; padding: 2px 6px; font-size: 11px; border-radius: 3px; line-height: 1.4; }
.btn-action-add    { background: #1e3a1e; border: 1px solid #4ec9b0; color: #4ec9b0; }
.btn-action-add:hover    { background: #264f26; }
.btn-action-block  { background: #3a1e1e; border: 1px solid #f44747; color: #f44747; }
.btn-action-block:hover  { background: #4f2626; }
.btn-action-forget { background: #2a2a1e; border: 1px solid #888; color: #888; }
.btn-action-forget:hover { background: #3a3a28; color: #aaa; }
.btn-action-edit   { background: #1e2a3a; border: 1px solid #9cdcfe; color: #9cdcfe; }
.btn-action-edit:hover   { background: #263a4f; }
.btn-action-retry  { background: #1e2a3a; border: 1px solid #ce9178; color: #ce9178; }
.btn-action-retry:hover  { background: #2a2010; }

#btn-manage-contacts, #btn-add-by-addr {
  background: none; border: none; color: #555; font-size: 14px;
  cursor: pointer; padding: 0; margin: 0; line-height: 1;
}
#btn-manage-contacts:hover, #btn-add-by-addr:hover { color: #9cdcfe; background: none; }

/* ── Sidebar: settings button ── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}
.btn-settings {
  width: 100%; background: #1e1e1e; border: 1px solid #444;
  color: #aaa; font-size: 12px; margin: 0;
}
.btn-settings:hover { background: #252526; }

#btn-open-contacts { cursor: pointer; }

.contact-list-empty { color: #555; font-size: 12px; }

/* ── Chat header ── */
#chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 28px; border-bottom: 1px solid #333;
  flex-shrink: 0; min-height: 56px;
}

/* ── Chat header: avatar and name ── */
.chat-header-avatar {
  border-radius: 6px; flex-shrink: 0;
}
.chat-header-info {
  flex: 1; min-width: 0;
}
#inbox-status { font-size: 11px; color: #555; }

/* ── Send form ── */
.send-row {
  display: flex; gap: 8px; align-items: flex-end;
}
#emoji-picker-wrap {
  position: relative; flex-shrink: 0; align-self: flex-end;
}
#emoji-btn {
  margin: 0; padding: 0; width: 36px; height: 36px;
  background: transparent; border: 1px solid #444;
  border-radius: 4px; font-size: 18px; line-height: 1; cursor: pointer;
}
#payload { flex: 1; margin: 0; resize: none; }
.btn-send {
  margin: 0; padding: 0 18px; flex-shrink: 0; align-self: flex-end;
}

/* ── Empty states ── */
.inbox-empty {
  color: #555; font-size: 13px;
}
.conv-list-empty {
  color: #555; font-size: 12px; padding: 8px 0;
}

/* ── Conversation list: row ── */
.conv-name {
  font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.online-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #4ec9b0;
  margin-left: 4px; vertical-align: middle;
  box-shadow: 0 0 4px #4ec9b0;
}
.conv-ts {
  font-size: 11px; color: #555; flex-shrink: 0;
}
.conv-row-top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 4px;
}
.conv-row-bottom {
  font-size: 11px; color: #666; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; display: flex; justify-content: space-between;
}
.conv-inner {
  flex: 1; min-width: 0; overflow: hidden;
}

/* ── Chat header: members button ── */
.btn-group-members {
  flex-shrink: 0; font-size: 12px; padding: 4px 8px; margin: 0;
  background: #1a2a3a; border: 1px solid #444;
}

/* ── Chat header: menu button ☰ ── */
.btn-conv-menu {
  flex-shrink: 0; margin: 0; padding: 4px 10px;
  background: transparent; border: 1px solid transparent;
  border-radius: 4px; font-size: 18px; color: #666; cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-left: auto;
}
.btn-conv-menu:hover { color: #9cdcfe; border-color: #444; }

/* ── Conversation dropdown menu ── */
.conv-menu-popup {
  position: fixed; z-index: 1000;
  background: #252526; border: 1px solid #444; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  min-width: 220px; padding: 4px 0;
}
.conv-menu-item {
  padding: 9px 16px; font-size: 13px; color: #d4d4d4; cursor: pointer;
  transition: background .12s;
}
.conv-menu-item:hover { background: #2d2d2d; color: #9cdcfe; }

/* ── Toast notification ── */
.conv-menu-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #2d2d2d; border: 1px solid #444; border-radius: 20px;
  padding: 8px 18px; font-size: 13px; color: #4ec9b0;
  z-index: 2000; pointer-events: none;
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Folder separators in sidebar ── */
.conv-folder-sep {
  font-size: 11px; color: #555; padding: 8px 12px;
  text-transform: uppercase; letter-spacing: .04em; user-select: none;
}
.conv-folder-archive {
  cursor: pointer; transition: color .15s;
}
.conv-folder-archive:hover { color: #888; }
.conv-folder-divider {
  height: 1px; background: #2a2a2a; margin: 4px 8px;
}
.conv-star {
  font-size: 11px; margin-left: 4px; vertical-align: middle;
}
