:root {
  --ink: #1b1f2a;
  --muted: #6b7280;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --accent: #4f5fe0;
  --accent-soft: #eceafe;
  --line: #e3e5ea;
  --max-width: 640px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { max-width: var(--max-width); margin: 0 auto; width: 100%; padding: 0 1.25rem; display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- Header ---------- */
header {
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1 { font-size: 1.15rem; margin: 0; }
header .sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
.live-badge .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

/* ---------- Join screen ---------- */
.join-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.join-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2.25rem;
  max-width: 380px;
  width: 100%;
}
.join-panel h2 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.join-panel p { color: var(--muted); font-size: 0.92rem; margin: 0 0 1.5rem; }
.join-panel input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.98rem;
  font-family: inherit;
  margin-bottom: 0.9rem;
}
.join-panel input:focus { outline: none; border-color: var(--accent); }
.join-panel button {
  width: 100%;
  padding: 0.8rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
}
.join-panel button:hover { background: #4350c4; }

/* ---------- Chat ---------- */
.chat-screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
.chat-screen.active { display: flex; }
.join-screen.hidden { display: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.msg { max-width: 78%; }
.msg .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 0.6rem 0.9rem;
  font-size: 0.94rem;
}
.msg .meta { font-size: 0.72rem; color: var(--muted); margin: 0 0.2rem 0.25rem; }
.msg.self { align-self: flex-end; }
.msg.self .bubble { background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 14px 14px 4px 14px; }
.msg.self .meta { text-align: right; }

.empty-chat { text-align: center; color: var(--muted); font-size: 0.9rem; margin: auto; }

.composer {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 0 1.25rem;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: inherit;
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer button {
  padding: 0 1.4rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.composer button:hover { background: #4350c4; }
.composer button:disabled { opacity: 0.6; cursor: not-allowed; }

.conn-note {
  text-align: center;
  font-size: 0.78rem;
  color: #b8860b;
  padding-bottom: 0.5rem;
  display: none;
}
.conn-note.show { display: block; }
