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

:root {
  --bg: #F4F1EA;
  --card: #FFFFFF;
  --text: #111111;
  --text-light: #555555;
  --border: #E0DDD6;
}

body {
  font-family: 'Open Sans', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* Welcome Screen */
#welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
}

.welcome-container {
  max-width: 480px;
  text-align: center;
}

.welcome-title {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.welcome-subtitle {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-light);
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

.safety-note {
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2.5rem;
  text-align: left;
  line-height: 1.7;
  font-size: 0.9rem;
  color: var(--text-light);
  border: 1px solid var(--border);
}

.pill-button {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.1em;
  background: var(--text);
  color: #FFFFFF;
  border: none;
  border-radius: 100px;
  padding: 1rem 3rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pill-button:hover {
  opacity: 0.85;
}

.pill-button:disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Welcome form */
.welcome-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}

.welcome-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.welcome-field-label {
  font-family: 'Open Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
}

.welcome-form input {
  font-family: 'Open Sans', sans-serif;
  font-size: 1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  outline: none;
}

.welcome-form input:focus {
  border-color: var(--text);
}

.welcome-form .pill-button {
  align-self: center;
  margin-top: 0.5rem;
}

.verify-error {
  font-family: 'Open Sans', sans-serif;
  font-size: 0.85rem;
  color: #8B0000;
  text-align: center;
  margin: -0.25rem 0 0.25rem;
}

#already-used-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
}

/* Chat Screen */
#chat-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

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

.chat-title {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--text);
}

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

.message {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: 20px;
  line-height: 1.65;
  font-size: 0.95rem;
  animation: fadeIn 0.3s ease;
}

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

.message-ai {
  background: var(--card);
  align-self: flex-start;
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.message-user {
  background: var(--text);
  color: #FFFFFF;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

/* Plan message (full markdown rendered) */
.message-plan {
  max-width: 95%;
}

.message-plan h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem 0;
  color: var(--text);
}

.message-plan h3:first-child {
  margin-top: 0;
}

.message-plan p {
  margin: 0.4rem 0;
  line-height: 1.7;
}

.message-plan blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.9rem;
  margin: 0.6rem 0;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.7;
}

.message-plan ul {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.message-plan li {
  margin: 0.35rem 0;
  line-height: 1.6;
}

.message-plan hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.message-plan strong {
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 0.75rem 1.25rem;
  align-self: flex-start;
  margin-left: 1rem;
  margin-bottom: 0.5rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Input */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

#user-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0.85rem 1.25rem;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  background: var(--card);
  color: var(--text);
  max-height: 120px;
  line-height: 1.4;
}

#user-input:focus {
  border-color: var(--text);
}

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.send-button:hover {
  opacity: 0.85;
}

/* Session Complete */
.session-complete-line {
  font-family: 'Open Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text-light);
  text-align: center;
  padding: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Download Button */
.download-button {
  margin: 0.5rem auto 1.5rem;
  flex-shrink: 0;
}

/* Scrollbar */
.messages-container::-webkit-scrollbar {
  width: 4px;
}

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

/* Mobile adjustments */
@media (max-width: 480px) {
  .welcome-title {
    font-size: 2rem;
  }

  .message {
    max-width: 90%;
  }

  #chat-screen {
    max-width: 100%;
  }
}
