:root {
  --bg: #0c0e12;
  --panel: #14171d;
  --panel-2: #1b1f27;
  --border: #2a2f3a;
  --text: #d7dce4;
  --muted: #7c8595;
  --accent: #39d98a;
  --accent-dim: #1f7a4f;
  --them: #8ab4ff;
  --bad: #ff6b6b;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hidden { display: none !important; }

#app { width: 100%; max-width: 720px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* ---- start / join screens ---- */

#start, #join {
  padding: 40px 32px;
  text-align: center;
}

#start h1, #join h1 {
  margin: 0 0 12px;
  font-size: 26px;
  letter-spacing: -0.5px;
}
#start h1 span, #join h1 span { color: var(--accent); }

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

#start .muted, #join .muted { margin: 0 auto 24px; max-width: 44ch; }
#start .small, #join .small { margin-top: 20px; }

.field {
  display: block;
  max-width: 280px;
  margin: 0 auto 16px;
  text-align: left;
}
.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
}
.field input:focus { outline: 1px solid var(--accent-dim); }

button {
  font-family: var(--mono);
  font-size: 14px;
  color: #04140c;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- chat screen ---- */

#chat { display: flex; flex-direction: column; height: min(80vh, 680px); }

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

.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--accent); }
.status.bad { color: var(--bad); }

.code {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
  cursor: help;
}

.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.members {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.members::-webkit-scrollbar { display: none; }

button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}
button.ghost:hover { background: rgba(57, 217, 138, 0.08); filter: none; }

.banner {
  padding: 12px 14px;
  background: rgba(57, 217, 138, 0.06);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.banner-label { font-size: 12px; color: var(--accent); }

.invite-row { display: flex; gap: 8px; }
.invite-row input {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  min-width: 0;
}
.invite-row button { padding: 7px 12px; font-size: 12px; }

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

#log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.line { word-break: break-word; }
.line .ts { color: #4b5262; font-size: 11px; margin-right: 8px; }
.line .who { font-weight: 600; margin-right: 8px; }
.line.me   .who { color: var(--accent); }
.line.them .who { color: var(--them); }
.line.sys  { color: var(--muted); font-style: italic; }
.line.sys .who { display: none; }
.line.sys .ts { color: #3a4150; }

.typing {
  min-height: 18px;
  padding: 0 14px 4px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

#composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
#composer input {
  flex: 1;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  min-width: 0;
}
#composer input:focus { outline: 1px solid var(--accent-dim); }

@media (max-width: 480px) {
  #start, #join { padding: 32px 20px; }
  #chat { height: 88vh; }
}
