:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1d222c;
  --border: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a5;
  --accent: #5b8cff;
  --accent-soft: #5b8cff22;
  --ok: #3ddc84;
  --warn: #ffb648;
  --err: #ff5c5c;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* ---------------------------------------------------------------- gate --- */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
}

.gate-card h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.gate-card h1 span {
  color: var(--muted);
  font-weight: 400;
}
.gate-card .sub {
  margin: 6px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.gate-card label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.gate-card input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.gate-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gate-card button {
  margin-top: 14px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.gate-card button:hover { filter: brightness(1.08); }

.gate-card .hint {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.gate-card .gate-error {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: #ff5c5c1a;
  border: 1px solid #ff5c5c40;
  color: #ff9b9b;
  font-size: 13px;
}

/* ---------------------------------------------------------------- room --- */

.room {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
}
.dot.online { background: var(--ok); }
.dot.offline { background: var(--err); }

.meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta .sep { opacity: 0.4; }

.messages {
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 3px 8px;
  border-radius: 6px;
}
.msg:hover { background: #ffffff08; }
.msg .who {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg.self .who { color: var(--accent); }

.msg.system {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  padding: 5px 8px;
}

.msg .time {
  color: #5d6474;
  font-size: 11px;
  margin-left: 6px;
}

.typing {
  padding: 4px 18px 6px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  min-height: 22px;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  outline: none;
}
.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer button {
  padding: 0 20px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.composer button:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .msg { grid-template-columns: 1fr; }
  .msg .who { text-align: left; }
}
