:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --text: #122034;
  --muted: #5d6a7f;
  --primary: #1d5bd6;
  --primary-dark: #0f3c97;
  --line: #d9e0eb;
  --online: #26b24b;
  --offline: #8a919c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

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

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}

label { display: block; margin-top: 10px; margin-bottom: 4px; font-weight: 600; }
input, textarea, button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
}

button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: pointer;
}
button:hover { background: var(--primary-dark); }

.alert {
  margin: 12px 0;
  padding: 8px 10px;
  background: #ffe7e7;
  color: #8e1b1b;
  border: 1px solid #ffcaca;
  border-radius: 8px;
}

.top-nav {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
}

.profile-view { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.chat-wrap {
  width: min(1000px, 96vw);
  margin: 16px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 96px);
}

.chat-head {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.status-row { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.dot-online { background: var(--online); }
.dot-offline { background: var(--offline); }

.emoji-panel { display: flex; gap: 6px; }
.emoji-btn { width: auto; padding: 8px 10px; }

.messages {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  max-width: min(700px, 100%);
}
.msg-item.mine {
  align-self: flex-end;
  background: #edf3ff;
}
.msg-item.theirs {
  align-self: flex-start;
  background: #f8fafc;
}

.msg-main p { margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.msg-meta { font-size: 12px; color: var(--muted); }
.msg-actions, .msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.msg-actions button, .reaction-pill {
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
}
.mine-react { border-color: var(--primary); }

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
}
.composer-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.file-label {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  font-size: 13px;
}
.file-label input { margin-top: 6px; }

.open-photo {
  width: auto;
  padding: 8px 12px;
}

.settings-wrap {
  width: min(560px, 94vw);
  margin: 26px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; }

@media (max-width: 720px) {
  .chat-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .composer-actions {
    flex-direction: column;
  }
}
