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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; display: flex; flex-direction: column; }

/* Login */
#login-screen {
  justify-content: center;
  align-items: center;
}

.login-box {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 48px;
  width: 380px;
  text-align: center;
}

.login-box h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #fff;
}

.subtitle {
  color: #666;
  font-size: 14px;
  margin-bottom: 32px;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: #0f0f0f;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus { border-color: #555; }

.login-box button {
  width: 100%;
  padding: 12px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.login-box button:hover { opacity: 0.9; }

.error { color: #e74c3c; font-size: 13px; margin-top: 12px; }

/* Chat */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #1a1a1a;
  background: #0f0f0f;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.header-left h2 { font-size: 16px; font-weight: 500; color: #999; }

#agent-select {
  padding: 6px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

.header-right { display: flex; align-items: center; gap: 12px; }

#user-name { color: #666; font-size: 14px; }

.btn-small {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  color: #999;
  font-size: 13px;
  cursor: pointer;
}

.btn-small:hover { border-color: #555; color: #e0e0e0; }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 720px;
  padding: 16px 20px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 15px;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: #1a3a5c;
  color: #d0e0f0;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-bottom-left-radius: 4px;
}

.message.tool-info {
  align-self: flex-start;
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #666;
  font-size: 13px;
  padding: 8px 14px;
}

.message.error {
  background: #3a1a1a;
  border: 1px solid #5a2a2a;
  color: #e0a0a0;
}

/* Chat Input */
.chat-input {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #1a1a1a;
  background: #0f0f0f;
}

#chat-input {
  flex: 1;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus { border-color: #555; }

#send-btn {
  padding: 12px 24px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  align-self: flex-end;
}

#send-btn:hover { opacity: 0.9; }
#send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Loading indicator */
.message.assistant.loading::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #666;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Markdown content in assistant messages */
.message.assistant p { margin-bottom: 8px; }
.message.assistant p:last-child { margin-bottom: 0; }
.message.assistant strong { color: #fff; }
.message.assistant em { color: #bbb; }

.message.assistant h1,
.message.assistant h2,
.message.assistant h3 {
  color: #fff;
  margin: 16px 0 8px 0;
}
.message.assistant h1:first-child,
.message.assistant h2:first-child,
.message.assistant h3:first-child { margin-top: 0; }
.message.assistant h1 { font-size: 18px; }
.message.assistant h2 { font-size: 16px; }
.message.assistant h3 { font-size: 15px; }

.message.assistant ul,
.message.assistant ol {
  margin: 8px 0;
  padding-left: 24px;
}
.message.assistant li { margin-bottom: 4px; }

.message.assistant code {
  background: #2a2a2a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.message.assistant pre {
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
}
.message.assistant pre code {
  background: none;
  padding: 0;
}

.message.assistant table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 14px;
}
.message.assistant th,
.message.assistant td {
  border: 1px solid #333;
  padding: 6px 12px;
  text-align: left;
}
.message.assistant th {
  background: #2a2a2a;
  color: #fff;
}

.message.assistant blockquote {
  border-left: 3px solid #444;
  padding-left: 12px;
  color: #999;
  margin: 8px 0;
}

.message.assistant a {
  color: #6ca6d9;
  text-decoration: none;
}
.message.assistant a:hover { text-decoration: underline; }

/* Scrollbar */
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
