:root {
  --bg: #0b1020;
  --panel: #131a2e;
  --panel-2: #1b243d;
  --text: #e8ecf5;
  --muted: #9aa6c2;
  --accent: #00c48c; /* SyncViz green */
  --user: #223052;
  --error: #ff6b6b;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font: inherit; }

/* --- Gate --- */
.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  padding: 28px 24px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gate-card h1 { margin: 0; font-size: 1.6rem; }
.gate-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.gate-card input, .composer textarea {
  background: var(--panel-2);
  border: 1px solid transparent;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
}
.gate-card input:focus, .composer textarea:focus { border-color: var(--accent); }
.gate-card button {
  background: var(--accent);
  color: #04231a;
  border: 0;
  padding: 12px;
  border-radius: 10px;
  font-weight: 600;
}
.error { color: var(--error); font-size: 0.85rem; }

/* --- App --- */
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 820px; margin: 0 auto; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-2);
}
.brand { font-weight: 700; letter-spacing: 0.3px; }
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-2);
  border-radius: 8px;
  padding: 6px 12px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg { max-width: 90%; padding: 12px 14px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 4px; }
.msg.assistant.error { border: 1px solid var(--error); }
.tool-note { align-self: flex-start; color: var(--muted); font-size: 0.8rem; font-style: italic; padding-left: 4px; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--panel-2);
}
.composer textarea { flex: 1; resize: none; max-height: 140px; }
.composer button {
  background: var(--accent);
  color: #04231a;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 600;
}
.composer button:disabled { opacity: 0.5; cursor: default; }
