:root {
  --bg: #212121;
  --sidebar: #171717;
  --user-bg: #2f2f2f;
  --text: #ececec;
  --text-muted: #b4b4b4;
  --accent: #10a37f;
  --border: #2f2f2f;
  --input-bg: #2f2f2f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.new-chat-btn, .settings-btn {
  margin: 12px;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.new-chat-btn:hover, .settings-btn:hover { background: #2f2f2f; }

.chat-list { flex: 1; overflow-y: auto; padding: 0 8px; }

.chat-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.chat-item:hover, .chat-item.active {
  background: #2f2f2f;
  color: var(--text);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* Main */
.chat-area { flex: 1; display: flex; flex-direction: column; }

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header h1 { font-size: 16px; font-weight: 600; }

.model-badge {
  font-size: 12px;
  background: #2f2f2f;
  padding: 3px 8px;
  border-radius: 12px;
  color: var(--text-muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}

.welcome {
  text-align: center;
  margin-top: 12vh;
  color: var(--text-muted);
  padding: 0 20px;
}

.welcome h2 {
  font-size: 28px;
  color: var(--text);
  margin-bottom: 12px;
}

.message {
  max-width: 768px;
  margin: 0 auto 24px;
  padding: 0 24px;
  display: flex;
  gap: 16px;
}

.message .avatar {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.message.user .avatar { background: #5436da; }
.message.assistant .avatar { background: var(--accent); }

.message .content {
  flex: 1;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user .content {
  background: var(--user-bg);
  padding: 12px 16px;
  border-radius: 12px;
}

/* Input */
.input-area {
  padding: 16px 24px 24px;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

#chat-form {
  display: flex;
  align-items: flex-end;
  background: var(--input-bg);
  border-radius: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  gap: 8px;
}

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

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

#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Typing */
.typing { display: flex; gap: 4px; padding: 8px 0; }
.typing span {
  width: 8px; height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: #2f2f2f;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
}

.modal-content h3 { margin-bottom: 8px; }
.modal-content p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

.modal-content label {
  display: block;
  font-size: 13px;
  margin: 12px 0 4px;
  color: var(--text-muted);
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #212121;
  color: var(--text);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.modal-actions button:first-child {
  background: var(--accent);
  color: white;
}

.modal-actions .secondary {
  background: #444;
  color: white;
}

.help {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
}
