* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  font-family: system-ui, sans-serif;
  background: #f7f7f8;
  color: #1f1f1f;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #1f2023;
  color: #e8e8e8;
  padding: 12px;
  overflow-y: auto;
}
#new-chat {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #4a4b50;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
#new-chat:hover { background: #2c2d31; }
#chat-list { list-style: none; margin: 0; padding: 0; }
#chat-list li {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
#chat-list li:hover { background: #2c2d31; }
#chat-list li.active { background: #3a3b40; }

/* ---------- Chat area ---------- */
main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#messages { flex: 1; overflow-y: auto; padding: 24px; }
.empty { color: #888; text-align: center; margin-top: 30vh; }

.message { max-width: 720px; margin: 0 auto 16px; }
.message .text {
  white-space: pre-wrap;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
}
.message.user .text { background: #2563eb; color: white; margin-left: auto; width: fit-content; max-width: 80%; }
.message.assistant .text { background: white; border: 1px solid #e3e3e3; }
.message.error .text { border-color: #dc2626; color: #dc2626; }

.feedback { margin-top: 4px; }
.feedback button {
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.4;
  font-size: 15px;
}
.feedback button:hover, .feedback button.selected { opacity: 1; }

/* ---------- Composer ---------- */
#composer {
  display: flex;
  gap: 8px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 24px;
}
#input {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  font: inherit;
}
#send {
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  cursor: pointer;
}
#send:disabled { background: #93a8d8; cursor: wait; }

/* Phones: sidebar on top */
@media (max-width: 640px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; max-height: 30vh; }
}
