:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #202532;
  --text: #e8ecf2;
  --muted: #b7c0cf;
  --accent: #5ba3ff;
  --danger: #ff6b6b;
  --ok: #4cd17e;
  --composer-h: 72px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body {
  overflow: hidden;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2b3241;
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
}

.status {
  font-size: 0.9rem;
  color: var(--muted);
}

.status--online { color: var(--ok); }
.status--offline { color: #ffbf66; }

.messages {
  overflow-y: auto;
  padding: 12px 12px calc(var(--composer-h) + 16px);
  overscroll-behavior: contain;
}

.msg {
  background: var(--panel-2);
  border: 1px solid #2f3748;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.msg-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.msg-name {
  color: #dbe6ff;
  font-weight: 600;
}

.msg-you {
  color: var(--accent);
  font-weight: 600;
}

.msg-text {
  font-size: 1rem;
  line-height: 1.4;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid #2b3241;
}

input, button {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #39435a;
  font-size: 16px;
}

input {
  width: 100%;
  padding: 0 12px;
  background: #121722;
  color: var(--text);
}

button {
  padding: 0 16px;
  background: var(--accent);
  color: #071326;
  border: none;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.jump-pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--composer-h) + 12px);
  z-index: 30;
  background: #2f64b7;
  color: #fff;
  border: none;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  font-size: 0.95rem;
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.7);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid #2b3241;
  border-radius: 14px;
  padding: 18px;
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.modal-card form {
  display: grid;
  gap: 10px;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #2b3241;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.toast.show {
  opacity: 1;
}

@media (min-width: 768px) {
  .messages {
    padding-left: 16px;
    padding-right: 16px;
  }

  .msg {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 12px;
  }

  .composer {
    padding-left: max(16px, calc((100vw - 900px) / 2));
    padding-right: max(16px, calc((100vw - 900px) / 2));
  }
}
