:root {
  --blue: #1d4f91;
  --blue-light: #e8eef7;
  --border: #c9d3e0;
  --text: #1c1e21;
  --muted: #6b7280;
  --red: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 "Lucida Grande", Tahoma, Verdana, sans-serif;
  color: var(--text);
  background: #f4f6f9;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

header { background: var(--blue); color: #fff; }
.bar, main { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 8px 16px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.logo { color: #fff; font-weight: bold; font-size: 20px; letter-spacing: 1px; }
.logo:hover { text-decoration: none; }
nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
nav a, nav button.link { color: #fff; }
nav input { width: 160px; padding: 4px 8px; border: 0; border-radius: 3px; }

main { padding-top: 20px; padding-bottom: 40px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.box { background: #fff; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 16px; }
.box > h2 {
  margin: 0; padding: 6px 12px; font-size: 13px;
  background: var(--blue-light); border-bottom: 1px solid var(--border); color: var(--blue);
}
.box > .body { padding: 12px; }

.cols { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 680px) { .cols { grid-template-columns: 1fr; } nav input { width: 110px; } }

.narrow { max-width: 560px; margin: 0 auto; }
.narrow p.lead { font-size: 16px; }

form.stack { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 3px; font-weight: bold; font-size: 12px; }
input, textarea, select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 3px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }

button {
  font: inherit; cursor: pointer; padding: 5px 12px; border-radius: 3px;
  border: 1px solid #16407a; background: var(--blue); color: #fff;
}
button.secondary { background: #fff; color: var(--blue); border-color: var(--border); }
button.link { background: none; border: 0; padding: 0; color: var(--blue); }
button.link.muted { color: var(--muted); }
a.button { display: inline-block; padding: 5px 12px; border-radius: 3px; border: 1px solid var(--border); background: #fff; }
a.button:hover { text-decoration: none; background: var(--blue-light); }
button:disabled { opacity: .6; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { justify-content: flex-end; }
.spread { justify-content: space-between; }
.nowrap { white-space: nowrap; }

.error { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

h1 { font-size: 22px; margin: 0 0 4px; }
.bio { white-space: pre-wrap; margin: 10px 0 0; }

ul.people { list-style: none; margin: 0; padding: 0; }
ul.people li { padding: 6px 0; border-bottom: 1px solid #eef1f5; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
ul.people li:last-child { border-bottom: 0; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 4px; object-fit: cover; background: var(--blue-light); color: var(--blue); font-weight: bold;
}
.profile-photo { margin-bottom: 10px; }
.profile-photo .avatar { width: 100% !important; height: auto !important; aspect-ratio: 1; font-size: 64px !important; }
.person { display: inline-flex; align-items: center; gap: 8px; color: var(--text); min-width: 0; }
.person:hover { text-decoration: none; }
.person:hover strong, .person:hover > span { text-decoration: underline; }
.badge { background: var(--red); color: #fff; border-radius: 9px; padding: 0 6px; margin-left: 4px; font-size: 11px; font-weight: bold; }

.post { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eef1f5; }
.post:last-child { border-bottom: 0; }
.post-main { flex: 1; min-width: 0; }
.post .meta { display: flex; justify-content: space-between; gap: 8px; }
.post .text { white-space: pre-wrap; margin-top: 3px; overflow-wrap: anywhere; }
.post-image { display: block; margin-top: 8px; max-width: 100%; max-height: 480px; border-radius: 4px; border: 1px solid #eef1f5; }
.post-form { margin-bottom: 8px; }
.preview { display: flex; align-items: flex-end; gap: 8px; }
.preview:empty { display: none; }
.preview img { max-height: 120px; max-width: 200px; border-radius: 4px; }

ul.people li.unread { background: #f7f9fd; }
ul.people li.unread strong::after { content: " •"; color: var(--red); }
.conv { flex: 1; }
.conv-text { display: flex; flex-direction: column; min-width: 0; }
.conv-text .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread-head { padding-bottom: 10px; border-bottom: 1px solid #eef1f5; }
.thread { display: flex; flex-direction: column; gap: 6px; height: min(60vh, 520px); overflow-y: auto; padding: 12px 0; }
.msg {
  max-width: 75%; align-self: flex-start; padding: 6px 10px; border-radius: 12px;
  background: #eef1f5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine { align-self: flex-end; background: var(--blue); color: #fff; }
