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

:root {
  --bg: #0f0f11;
  --surface: #1a1a1f;
  --border: #2e2e38;
  --accent: #f6821f;       /* Cloudflare orange */
  --accent2: #6c47ff;      /* OpenRouter purple */
  --text: #e8e8f0;
  --muted: #6b6b80;
  --user-bg: #1e1e2e;
  --ai-bg: #16161e;
  --radius: 14px;
  --font: 'Inter', system-ui, 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: 780px;
  margin: 0 auto;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 12px;
}
.logo { font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.model-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Chat Window ── */
main { flex: 1; overflow: hidden; }
.chat-window {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.empty-state {
  margin: auto;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* ── Messages ── */
.msg {
  display: flex;
  gap: 12px;
  animation: fadeUp 0.18s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  background: var(--border);
}
.msg.user .avatar  { background: var(--accent); }
.msg.ai   .avatar  { background: var(--accent2); }

.bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--border);
  border-top-right-radius: 4px;
}
.msg.ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.bubble.error { border-color: #e53e3e; color: #fc8181; }

/* Typing dots */
.typing { display: flex; align-items: center; gap: 5px; padding: 14px 16px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ── Footer / Input ── */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px 14px;
}
#form { display: flex; gap: 10px; align-items: flex-end; }

#input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  resize: none;
  max-height: 160px;
  transition: border-color 0.15s;
  outline: none;
  line-height: 1.5;
}
#input:focus { border-color: var(--accent); }

#send-btn {
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#send-btn:hover  { background: #e07318; }
#send-btn:active { transform: scale(0.94); }
#send-btn:disabled { background: var(--border); cursor: not-allowed; }

.hint {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}
