:root {
  --bg: #10101f;
  --panel: #1b1b2e;
  --panel-2: #24243c;
  --text: #e8e8f2;
  --muted: #9a9ab8;
  --accent: #4f7cff;
  --accent-2: #3b63d6;
  --danger: #ff6b6b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2c2c46;
}

header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.nick-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nick-wrap label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.nick-wrap input {
  width: 150px;
  padding: 8px 10px;
  font-size: 14px;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
}

button:hover { background: var(--accent-2); }

button:disabled {
  opacity: 0.6;
  cursor: default;
}

input {
  background: var(--panel);
  border: 1px solid #2c2c46;
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 16px;
}

input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.error {
  color: var(--danger);
  min-height: 20px;
  font-size: 14px;
  margin: 10px 0 0;
}

.status {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
  margin: 8px 0 0;
}

#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 12px;
  min-height: 200px;
}

.msg {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-width: 85%;
  align-self: flex-start;
}

.msg.own {
  background: var(--panel-2);
  align-self: flex-end;
}

.msg-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.author {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.time {
  font-size: 11px;
  color: var(--muted);
}

.text {
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

#send-form {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
}

#send-text { flex: 1; }

@media (max-width: 480px) {
  .msg { max-width: 92%; }
  header { flex-wrap: wrap; }
  header h1 { font-size: 18px; }
}
