:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --surface-hover: #222228;
  --border: #2a2a32;
  --text: #e8e8ed;
  --text-muted: #8a8a96;
  --accent: #7c6ef6;
  --accent-hover: #8f82f7;
  --user-msg: #2d2d38;
  --bella-msg: #25252d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.settings-btn {
  margin-bottom: 1rem;
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.settings-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.api-key-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.api-key-section label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.api-key-section input {
  flex: 1;
  min-width: 180px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

.api-key-section input:focus {
  outline: none;
  border-color: var(--accent);
}

.api-key-section button {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.api-key-section button:hover {
  background: var(--accent-hover);
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.welcome {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.msg {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.msg.user .msg-avatar {
  background: var(--accent);
}

.msg.bella .msg-avatar {
  background: var(--surface-hover);
}

.msg-content {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .msg-content {
  background: var(--user-msg);
}

.msg.bella .msg-content {
  background: var(--bella-msg);
}

.msg.loading .msg-content {
  color: var(--text-muted);
}

.input-area {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

.input-area textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 160px;
}

.input-area textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.input-area textarea::placeholder {
  color: var(--text-muted);
}

.input-area button {
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-end;
}

.input-area button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.input-area button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  color: var(--text);
}

.modal-hint {
  margin: 0;
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal #promptEditor {
  flex: 1;
  min-height: 200px;
  margin: 0 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.modal #promptEditor:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.modal-actions button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
}

.modal-actions button:hover {
  border-color: var(--accent);
}

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

.modal-actions button.primary:hover {
  background: var(--accent-hover);
}
