/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0d0d0f;
  --surface:    #16161a;
  --border:     #2a2a30;
  --accent:     #5865f2;
  --accent-dim: #3c45a5;
  --text:       #e8e8f0;
  --text-dim:   #8888a0;
  --user-bg:    #1e1e28;
  --jack-bg:    #111118;
  --radius:     12px;
  --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }

/* ── Layout ───────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.version {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.08em;
}

/* ── Chat window ──────────────────────────────────────────────────── */
main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  scroll-behavior: smooth;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Message bubbles ──────────────────────────────────────────────── */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fadein 0.2s ease;
}

.message.user { align-self: flex-end; align-items: flex-end; }
.message.jack  { align-self: flex-start; align-items: flex-start; }

.message .label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.message .bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.message.user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
}

.message.jack .bubble {
  background: var(--jack-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ─────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ── Input footer ─────────────────────────────────────────────────── */
footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color 0.2s;
}

#chat-form:focus-within { border-color: var(--accent); }

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  max-height: 160px;
  overflow-y: auto;
}

#user-input::placeholder { color: var(--text-dim); }

#send-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

#send-btn:hover { background: var(--accent-dim); }
#send-btn:disabled { background: var(--border); cursor: not-allowed; }

#send-btn svg { width: 16px; height: 16px; color: white; }

/* ── Animations ───────────────────────────────────────────────────── */
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Error state ──────────────────────────────────────────────────── */
.message.error .bubble {
  background: #2a1014;
  border-color: #5a1a20;
  color: #f08090;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
