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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
}

/* Layout */
.chat-layout {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #16162a;
  border-right: 1px solid #2a2a4a;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.sidebar__new-chat {
  width: 100%;
  padding: 10px 16px;
  background: #3a3a6a;
  color: #fff;
  border: 1px solid #4a4a8a;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 12px;
}

.sidebar__new-chat:hover {
  background: #4a4a8a;
}

.sidebar__sessions {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__session {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: #b0b0d0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__session:hover {
  background: #2a2a4a;
}

.sidebar__session--active {
  background: #2a2a4a;
  color: #fff;
}

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

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

.message-list__empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #606080;
  font-size: 18px;
}

.message-list__typing {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  color: #8080b0;
  font-style: italic;
  font-size: 14px;
  padding: 8px 0;
}

/* Messages */
.message {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.message__role {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  color: #8080b0;
}

.message--user .message__role {
  color: #6a9fea;
}

.message--assistant .message__role {
  color: #ea8a6a;
}

.message__content {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message--user .message__content {
  background: #2a2a4a;
  padding: 12px 16px;
  border-radius: 8px;
}

.message__tools {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.message__tool-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #2a2a4a;
  border: 1px solid #3a3a6a;
  border-radius: 4px;
  font-size: 11px;
  color: #8080b0;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Input */
.message-input {
  padding: 16px 24px;
  border-top: 1px solid #2a2a4a;
  display: flex;
  gap: 12px;
  max-width: 848px;
  width: 100%;
  margin: 0 auto;
}

.message-input textarea {
  flex: 1;
  padding: 12px 16px;
  background: #2a2a4a;
  border: 1px solid #3a3a6a;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 44px;
}

.message-input textarea:focus {
  border-color: #6a6aaa;
}

.message-input textarea:disabled {
  opacity: 0.5;
}

.message-input button {
  padding: 0 20px;
  background: #5a5aaa;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.message-input button:hover:not(:disabled) {
  background: #6a6abb;
}

.message-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Sidebar footer */
.sidebar__footer {
  border-top: 1px solid #2a2a4a;
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar__user {
  font-size: 12px;
  color: #8080b0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__sign-out {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: #b0b0d0;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.sidebar__sign-out:hover {
  background: #2a2a4a;
  color: #fff;
}

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: #16162a;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
}

.auth-title {
  font-size: 24px;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 24px;
  text-align: center;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: 13px;
  color: #8080b0;
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  background: #2a2a4a;
  border: 1px solid #3a3a6a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.auth-field input:focus {
  border-color: #6a6aaa;
}

.auth-error {
  background: #3a1a1a;
  border: 1px solid #6a2a2a;
  color: #ea8a6a;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  background: #5a5aaa;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  margin-top: 8px;
}

.auth-submit:hover:not(:disabled) {
  background: #6a6abb;
}

.auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #8080b0;
}

.auth-link a {
  color: #6a9fea;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: #2a2a4a;
  border: 1px solid #3a3a6a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 20px;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: #3a3a6a;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.5);
  }

  .chat-main {
    position: relative;
  }

  .message-list {
    padding: 48px 16px 16px;
  }

  .message-input {
    padding: 12px 16px;
  }
}
