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

:root {
  --primary: #f38020;
  --primary-dark: #e06d0d;
  --secondary: #0051c3;
  --success: #16a34a;
  --error: #dc2626;
  --bg: #0f0f0f;
  --bg-light: #1a1a1a;
  --bg-card: #242424;
  --text: #e5e5e5;
  --text-dim: #a3a3a3;
  --border: #404040;
  --message-user: #2563eb;
  --message-assistant: #374151;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  display: flex;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  width: 280px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed {
  margin-left: -280px;
}

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

.sidebar-header h3 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--bg-light);
}

.btn-new-conversation {
  margin: 16px;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-new-conversation:hover {
  background: var(--primary-dark);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.conversation-item {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.conversation-item:hover {
  background: var(--border);
  border-color: var(--primary);
}

.conversation-item.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.conversation-persona {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.conversation-preview {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.active .conversation-preview {
  color: rgba(255, 255, 255, 0.8);
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.conversation-item.active .conversation-time {
  color: rgba(255, 255, 255, 0.7);
}

.conversation-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  background: #b91c1c;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  min-width: 0;
}

.header {
  text-align: center;
  padding: 20px 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.header h1 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.persona-selector {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.persona-selector label {
  font-weight: 600;
  white-space: nowrap;
}

#personaSelect {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

#personaSelect:hover {
  border-color: var(--primary);
}

#personaSelect:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.1);
}

.btn-secondary {
  padding: 10px 18px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--border);
  border-color: var(--text-dim);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cutoff-banner {
  background: linear-gradient(135deg, #4a1d96 0%, #2b0f5c 100%);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid #6b21a8;
  text-align: center;
}

.chat-container {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 500px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--bg-light);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.welcome-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.welcome-message h2 {
  color: var(--primary);
  margin-bottom: 16px;
}

.welcome-message p {
  margin-bottom: 12px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

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

.message.assistant .message-avatar {
  background: var(--message-assistant);
}

.message-content {
  background: var(--bg-light);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  word-wrap: break-word;
}

.message.user .message-content {
  background: var(--message-user);
  border-color: var(--message-user);
}

.message-role {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.message-text {
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-streaming {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
  margin-left: 4px;
}

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

.chat-input-container {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

.message-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(243, 128, 32, 0.1);
}

.message-input::placeholder {
  color: var(--text-dim);
}

.btn-primary {
  padding: 12px 28px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.footer {
  text-align: center;
  padding: 24px 0;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.9rem;
}

.tech-stack {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 16px 20px;
  border-radius: 8px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-error {
  background: var(--error);
  color: white;
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 200px;
  }

  .sidebar.collapsed {
    margin-left: 0;
    max-height: 0;
    overflow: hidden;
  }

  .main-content {
    padding: 12px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .persona-selector {
    flex-direction: column;
    align-items: stretch;
  }

  .message {
    max-width: 95%;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}

