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

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e4e4e0;
  --accent: #2c2c2c;
  --system: #8a8a8a;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ---------- Join screen ---------- */
#join-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.join-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.join-box h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.join-box p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

#name-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}

#name-input:focus {
  border-color: var(--accent);
}

#join-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

#join-btn:hover {
  opacity: 0.9;
}

#join-btn:active {
  opacity: 0.8;
}

/* ---------- Chat screen ---------- */
#chat-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#status {
  font-size: 0.8rem;
  color: var(--muted);
}

main#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 85%;
}

.msg .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.msg .text {
  font-size: 0.95rem;
  word-break: break-word;
}

.msg.system {
  align-self: center;
  max-width: 100%;
  text-align: center;
  color: var(--system);
  font-size: 0.8rem;
  margin: 4px 0;
}

.msg.own {
  align-self: flex-end;
  text-align: right;
}

.msg.own .meta {
  order: 1;
}

footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#msg-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

#msg-input:focus {
  border-color: var(--accent);
}

#send-btn {
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

#send-btn:hover {
  opacity: 0.9;
}

#send-btn:active {
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 600px) {
  #chat-screen {
    border: none;
  }
  header, main#messages, footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ---------- Privacy additions ---------- */
.join-box .fine {
  font-size: 0.75rem;
  margin: 16px 0 0;
}

.link-btn {
  margin-left: auto;
  margin-right: 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
}
