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

:root {
  --bg: #f5f0e8;
  --bg-warm: #ece5d8;
  --text: #3a3630;
  --text-light: #8a8279;
  --accent: #6b5e50;
  --user-bg: #e2dbd0;
  --alan-bg: #ffffff;
  --border: #d4cbbf;
  --error: #a85a4a;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

.screen {
  height: 100%;
}

.screen[hidden] {
  display: none !important;
}

/* --- Login --- */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  text-align: center;
  max-width: 420px;
  width: 100%;
  padding: 0 1.5rem;
}

.login-container h1 {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 2.5rem;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#login-form input {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--accent);
}

#login-form button {
  padding: 0.7rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 0.25rem;
}

#login-form button:hover {
  opacity: 0.85;
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* --- Chat --- */

#chat-screen {
  display: flex;
  flex-direction: column;
}

#chat-screen header {
  text-align: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

#chat-screen header h1 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.04em;
}

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

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

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

.message.alan {
  align-self: flex-start;
  background: var(--alan-bg);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.message.thinking {
  color: var(--text-light);
  font-style: italic;
  animation: breathe 2.5s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.welcome {
  color: var(--text-light);
  font-style: italic;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.7;
  text-align: center;
  max-width: 420px;
  margin: auto;
  padding: 2rem 1rem;
}

/* --- Chat form --- */

#chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--accent);
}

#send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

#send-btn:hover {
  opacity: 0.85;
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* --- Responsive --- */

@media (min-width: 600px) {
  #messages {
    padding: 2rem;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
  }

  #chat-form {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    padding: 0.75rem 0;
    padding-bottom: 1rem;
  }

  .message {
    max-width: 80%;
  }
}
