* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0e1116;
  --bg-elevated: #171b22;
  --border: #262b33;
  --text: #e6e8eb;
  --text-dim: #8b929e;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --online: #3ecf6e;
  --offline: #565d68;
  --danger: #ff5c5c;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* --- Логин --- */

#login-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 8px;
  text-align: center;
}

.login-box input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
}

.login-box input:focus {
  border-color: var(--accent);
}

.login-box button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.login-box button:active {
  opacity: 0.8;
}

.error-text {
  color: var(--danger);
  font-size: 14px;
  min-height: 18px;
  text-align: center;
}

/* --- Чат --- */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

#peer-name {
  font-size: 16px;
  font-weight: 600;
}

.status-text {
  font-size: 13px;
  color: var(--offline);
}

.status-text.online {
  color: var(--online);
}

#logout-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.35;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-text);
  border-bottom-right-radius: 4px;
}

.message.theirs {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-time {
  display: block;
  font-size: 11px;
  opacity: 0.65;
  margin-top: 4px;
  text-align: right;
}

.message-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.message-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 16px;
  outline: none;
}

.message-form input:focus {
  border-color: var(--accent);
}

.message-form button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.message-form button:active {
  opacity: 0.8;
}
