* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  color: #222;
  background: #fafafa;
}

aside {
  border-right: 1px solid #ddd;
  background: #f3f3f1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.me {
  padding: 12px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  gap: 8px;
}
.me-text { flex: 1; min-width: 0; }

.icon-btn {
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  color: #555;
}
.icon-btn:hover { background: #ebebe9; }

.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.modal-card {
  position: relative;
  background: white; padding: 24px; border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column; gap: 16px;
  align-items: center;
  max-width: 360px;
}
.modal-card h2 { margin: 0; font-size: 16px; }
.qr { background: white; padding: 8px; }
.qr svg { display: block; }
.share-address {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  text-align: center;
  background: #f3f3f1;
  padding: 8px;
  border-radius: 4px;
  width: 100%;
}
.modal-actions { display: flex; gap: 8px; }
.modal-actions button {
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  cursor: pointer;
}
.modal-actions button:hover { background: #f3f3f1; }

.me .label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#me-address {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  display: block;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: #888;
  padding: 12px 12px 4px;
  letter-spacing: 0.05em;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.peer-row a.peer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  color: inherit;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.peer-row a.peer:hover { background: #ebebe9; }
.peer-row.active a.peer { background: #e0e8e0; border-left-color: #2d5016; }
#public-link {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
}
#public-link:hover { background: #ebebe9; }
#public-link.active { background: #e0e8e0; border-left-color: #2d5016; }

.avatar-sm { width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0; }
.peer-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.peer-addr { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.peer-sub {
  font-size: 11px; color: #888;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
  background: #b14216; color: white;
  font-size: 10px; padding: 2px 6px; border-radius: 10px;
}

.follow-form {
  padding: 8px 12px;
  display: flex; gap: 4px;
  border-top: 1px solid #ddd;
  margin-top: auto;
}
.follow-form input {
  flex: 1; padding: 4px 6px; font-size: 11px;
  font-family: ui-monospace, Menlo, monospace;
  border: 1px solid #ccc; border-radius: 4px;
}
.follow-form button {
  padding: 4px 8px; font-size: 12px;
  border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer;
}

main { display: flex; flex-direction: column; min-width: 0; }

header.main-head {
  padding: 12px 16px;
  border-bottom: 1px solid #ddd;
  background: white;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 14px;
}

#error {
  display: none;
  background: #fde6e6; color: #7a1f1f;
  padding: 8px 12px; border-bottom: 1px solid #f5c6cb;
  font-size: 13px;
}

#messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.empty { color: #888; text-align: center; padding: 32px; }

.msg { display: flex; gap: 8px; padding: 4px 0; }
.msg .avatar { width: 32px; height: 32px; border-radius: 4px; flex-shrink: 0; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.msg-from { font-family: ui-monospace, Menlo, monospace; color: #555; }
.msg-time { color: #999; font-size: 11px; }
.msg-text {
  font-size: 14px; line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg-text p { margin: 2px 0; }
.msg-text code { background: #eee; padding: 0 4px; border-radius: 3px; }

.composer {
  border-top: 1px solid #ddd;
  background: white;
  padding: 8px 12px;
  display: flex; gap: 8px;
}
#input {
  flex: 1; resize: none; padding: 8px; min-height: 40px; max-height: 200px;
  border: 1px solid #ccc; border-radius: 4px;
  font-family: inherit; font-size: 14px;
}
#send {
  padding: 8px 16px; background: #2d5016; color: white; border: none; border-radius: 4px;
  cursor: pointer; font-weight: 500;
}
#send:disabled { background: #888; cursor: not-allowed; }
