:root {
  --text-color: light-dark(black, white);
  --bg-color: light-dark(#fff, #121212);
  --user-bg: light-dark(#e1f5fe, #0277bd);
  --model-bg: light-dark(#f0f4f9, #2a2a2a);
  --input-bg: light-dark(#fff, #2a2a2a);
  --input-border: light-dark(#e0e0e0, #444);
  --button-color: light-dark(#007bff, #bb86fc);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  padding: 0.75rem 1.25rem;
  border-radius: 18px;
  max-width: 80%;
  line-height: 1.5;
  word-wrap: break-word;
}

.message div > :first-child {
    margin-top: 0;
}

.message div > :last-child {
    margin-bottom: 0;
}

.user-message {
  background-color: var(--user-bg);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.model-message {
  background-color: var(--model-bg);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

#chat-form {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--input-border);
  background-color: var(--bg-color);
}

#chat-input {
  flex: 1;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--text-color);
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  line-height: 1.5;
  max-height: 150px;
  scrollbar-width: none;
}

#chat-input:focus {
  outline: none;
  border-color: var(--button-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--button-color) 20%, transparent);
}

#chat-form button {
  background: none;
  border: none;
  padding: 0.75rem;
  cursor: pointer;
  color: var(--button-color);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

#chat-form button:hover:not(:disabled),
#chat-form button:focus-visible:not(:disabled) {
  background-color: color-mix(in srgb, var(--button-color) 15%, transparent);
}

#chat-form button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 0;
}

.loading-indicator span {
    width: 8px;
    height: 8px;
    background-color: currentColor;
    border-radius: 50%;
    opacity: 0.8;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-indicator span:nth-child(1) { animation-delay: -0.32s; }
.loading-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

.error {
    color: light-dark(#d32f2f, #ef9a9a);
}
