* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d1c1d;
}
.hidden { display: none !important; }
.error { color: #c0392b; min-height: 1em; }

.auth {
  max-width: 320px;
  margin: 12vh auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth input, .composer input[type=text], .composer input:not([type]) {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
}
.auth .row { display: flex; gap: 8px; }
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background: #611f69;
  color: #fff;
  padding: 8px 12px;
  font-size: 14px;
}
button:hover { background: #4a154b; }

.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.app:has(.thread:not(.hidden)) {
  grid-template-columns: 240px 1fr 340px;
}

.sidebar {
  background: #3f0e40;
  color: #cfc3cf;
  overflow-y: auto;
  padding-bottom: 20px;
}
.me {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #522653;
}
.me button { background: transparent; padding: 2px 6px; }
.section-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.section-head button { background: transparent; padding: 0 6px; font-size: 16px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li {
  padding: 5px 16px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar li:hover { background: #350d36; }
.sidebar li.active { background: #1164a3; color: #fff; }

.main, .thread { display: flex; flex-direction: column; min-height: 0; }
.thread { border-left: 1px solid #e8e8e8; }
header {
  padding: 12px 16px;
  border-bottom: 1px solid #e8e8e8;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header button { background: transparent; color: #1d1c1d; font-size: 18px; }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px; }
.msg { padding: 6px 0; }
.msg .meta { font-size: 13px; }
.msg .author { font-weight: 700; }
.msg .time { color: #888; margin-left: 6px; font-size: 12px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg a { color: #1264a3; }
.msg .attach a { display: inline-block; margin-top: 4px; }
.msg .reactions { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.msg .reactions .pill {
  background: #efefef;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
}
.msg .reactions .pill.mine { background: #e8f0fb; border-color: #1264a3; }
.msg .tools { visibility: hidden; font-size: 12px; }
.msg:hover .tools { visibility: visible; }
.msg .tools button {
  background: transparent;
  color: #1264a3;
  padding: 0 6px;
}
.msg .thread-link { color: #1264a3; cursor: pointer; font-size: 12px; }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e8e8e8;
  align-items: center;
}
.composer input:not([type]), .composer input[type=text] { flex: 1; }
.composer input[type=file] { max-width: 130px; font-size: 12px; }
