/* Nihehe messages page redesign: loaded LAST by messages.html. Remove the <link> to roll back. */
html, body { font-family: var(--font); background: var(--page); color: var(--brand); }
button, input, select, textarea { font-family: var(--font); }

.page {
  height: calc(100vh - 68px);
  height: calc(100dvh - 68px - env(safe-area-inset-top));
  max-width: 1100px; margin: 0 auto; padding: 16px; gap: 16px;
}

/* ---------- Conversation list ---------- */
.conversation-list {
  width: 340px; flex: 0 0 340px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}
.list-header { padding: 24px 24px 16px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--muted); font: 800 11px/1 var(--font); letter-spacing: .12em; }
.list-header h1 { margin: 8px 0 0; font: 800 26px/1.2 var(--font); color: var(--brand); }
#conversation-list { padding: 8px; }
#conversation-list > div[style] { color: var(--muted) !important; font-size: 15px !important; line-height: 1.5 !important; padding: 20px 16px !important; }
.conversation {
  width: 100%; min-height: 64px; margin: 0 0 4px; padding: 14px 16px; border: 0; border-radius: 20px;
  transition: background-color .15s var(--ease);
}
.conversation:hover, .conversation.active { background: var(--brand-light); }
.conversation:focus-visible, .composer textarea:focus-visible, .thread-back:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.conversation-title { font: 800 15px/1.3 var(--font); color: var(--brand); margin-bottom: 4px; }
.conversation-meta { font: 600 13px/1.3 var(--font); color: var(--muted); margin-bottom: 6px; }
.conversation-preview {
  font: 400 14px/1.4 var(--font); color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.unread {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: var(--radius-pill); background: var(--accent); color: var(--brand); font: 800 12px/1 var(--font); vertical-align: middle;
}

/* ---------- Thread ---------- */
.thread { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; }
.thread-empty-icon {
  width: 72px; height: 72px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--brand-light); color: var(--brand); font-size: 30px; opacity: 1;
}
.thread-empty h2 { font: 800 22px/1.3 var(--font); color: var(--brand); }
.thread-empty p { font-size: 15px; line-height: 1.6; color: var(--muted); }
.thread-header { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-heading { min-width: 0; }
.thread-header h2 { margin: 0 0 2px; font: 800 18px/1.3 var(--font); color: var(--brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-header .thread-heading div { font: 600 13px/1.3 var(--font); color: var(--muted); }
.thread-back {
  display: none; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px;
  border: 0; border-radius: var(--radius-pill); background: var(--brand-light); color: var(--brand); font-size: 20px; cursor: pointer;
}
.messages { padding: 20px; background: var(--page); }
#message-list > div[style] { color: var(--muted) !important; font-size: 15px !important; }

.message, .message.mine { max-width: 78%; padding: 10px 16px; animation: nh-rise .3s var(--ease) both; }
.message { background: var(--surface); border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; color: var(--brand); }
.message.mine { background: var(--brand); border-color: var(--brand); color: #fff; border-radius: 20px 20px 6px 20px; }
.message-body { font-size: 15px; line-height: 1.5; }
.message-time { font-size: 12px; color: var(--muted); }
.message.mine .message-time { color: rgba(255, 255, 255, .7); }
.date-separator span { font: 600 12px/1 var(--font); color: var(--brand); background: var(--brand-light); padding: 6px 12px; border-radius: var(--radius-pill); }

/* ---------- Composer and errors ---------- */
.thread-error {
  display: none; margin: 12px 16px 0; padding: 12px 16px; border-radius: 16px; background: #fdeceb; color: var(--danger);
  font: 600 14px/1.45 var(--font);
}
.thread-error.show { display: block; animation: nh-rise .25s var(--ease) both; }
.thread-error .hint { margin-top: 4px; color: var(--muted); font-weight: 400; }
.error { margin: 12px 16px; padding: 12px 16px; border-radius: 16px; background: #fdeceb; color: var(--danger); font: 600 14px/1.45 var(--font); }
.composer { gap: 10px; align-items: flex-end; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { min-height: 48px; padding: 13px 18px; border: 1.5px solid var(--line); border-radius: 24px; font-size: 16px; line-height: 1.4; color: var(--brand); }
.composer textarea:focus { border-color: var(--accent); }
.composer button {
  align-self: stretch; min-width: 88px; min-height: 48px; padding: 0 24px; border: 0; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--brand); font: 800 15px/1 var(--font); transition: transform .15s var(--ease);
}
.composer button:active { transform: scale(.98); }
.composer button:disabled { opacity: .6; }

/* ---------- Phones ---------- */
@media (max-width: 800px) {
  .page { padding: 0; gap: 0; }
  .conversation-list, .thread { border: 0; border-radius: 0; box-shadow: none; }
  .thread-back { display: inline-flex; }
  .message, .message.mine { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  .message, .thread-error.show { animation: none; }
  .conversation, .composer button { transition: none; }
}

/* ---------- Read receipts ---------- */
.message.mine .message-time .seen { color: var(--accent); font-weight: 600; }
