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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  background: #ffffff;
  min-height: 100vh;
  color: #353740;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e6;
  z-index: 100;
  padding: 12px 0;
}

.header-content {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: #10a37f;
  letter-spacing: -0.5px;
  margin: 0;
}

.help-btn {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s;
  line-height: 1;
}

.help-btn:hover {
  background: #f7f7f8;
  transform: scale(1.1);
}

.help-btn:active {
  background: #e5e5e6;
  transform: scale(0.95);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 1001;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 0;
  border-bottom: 1px solid #e5e5e6;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: #353740;
  margin: 0;
}

.close-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  background: #f7f7f8;
  transform: scale(1.1);
}

.close-btn:active {
  transform: scale(0.95);
}

.modal-body {
  padding: 0 24px 24px;
}

.modal-body h3 {
  font-size: 18px;
  font-weight: 600;
  color: #353740;
  margin-bottom: 12px;
}

.modal-body p {
  font-size: 15px;
  line-height: 1.6;
  color: #353740;
  margin-bottom: 16px;
}

.modal-body ol {
  margin-left: 20px;
  margin-bottom: 16px;
}

.modal-body li {
  font-size: 15px;
  line-height: 1.8;
  color: #353740;
  margin-bottom: 12px;
}

.modal-body li strong {
  color: #10a37f;
}

.modal-body .note {
  background: #f7f7f8;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid #10a37f;
  margin-top: 20px;
  font-size: 14px;
}

.modal-body .note strong {
  color: #10a37f;
}

.container {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 80px 24px 120px;
  display: flex;
  flex-direction: column;
  margin-top: 60px;
}

/* Initial centered view */
.container.initial-view {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.container.initial-view .chat-container {
  padding: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 0;
}

.container.initial-view .input-container {
  position: relative;
  padding: 0 24px;
  border-top: none;
  max-width: 620px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0;
}

.container.initial-view .welcome-message {
  margin-bottom: 32px;
  text-align: center;
}

.welcome-message {
  text-align: center;
  margin: auto 0;
}

.welcome-message h1 {
  font-size: 32px;
  font-weight: 600;
  color: #353740;
  margin-bottom: 8px;
}

.message {
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease-in;
  display: flex;
  flex-direction: column;
}

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

.message.user {
  align-items: flex-end;
}

.message.ai {
  align-items: flex-start;
}

.message-content {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 16px;
}

.message.user .message-content {
  background: #10a37f;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.ai .message-content {
  background: #f7f7f8;
  color: #353740;
  border-bottom-left-radius: 4px;
  white-space: pre-wrap;
}

.input-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 12px 16px 24px;
  border-top: 1px solid #e5e5e6;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
}

.container.initial-view .input-container {
  position: relative;
  border-top: none;
  padding-bottom: 0;
}

.input-wrapper {
  width: 100%;
  max-width: 768px;
  display: flex;
  align-items: flex-end;
  background: #f7f7f8;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  padding: 8px 12px;
  gap: 8px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.container.initial-view .input-wrapper {
  background: #f7f7f8;
}

.container:not(.initial-view) .input-wrapper {
  background: #ffffff;
  border: 1px solid #d1d5db;
}

.input-wrapper:focus-within {
  border-color: #10a37f;
  box-shadow: 0 2px 12px rgba(16, 163, 127, 0.15);
}

#questionInput {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 4px;
  font-size: 16px;
  outline: none;
  color: #353740;
  min-width: 0;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  overflow-y: auto;
  max-height: 120px;
}

#questionInput::placeholder {
  color: #8e8ea0;
}

.submit-btn {
  background: #10a37f;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
  color: white;
}

.submit-btn:hover {
  background: #0d8f6e;
  transform: scale(1.1);
}

.submit-btn:active {
  background: #0b7a5d;
  transform: scale(0.95);
}

.submit-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f7f7f8;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #8e8ea0;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Scrollbar styling */
.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Responsive design */
@media (max-width: 768px) {
  .header-content {
    padding: 0 16px;
  }

  .logo {
    font-size: 18px;
  }

  .chat-container {
    padding: 40px 16px 120px;
    margin-top: 60px;
  }

  .container.initial-view .chat-container {
    margin-top: 0;
  }

  .welcome-message h1 {
    font-size: 28px;
  }

  .message-content {
    max-width: 90%;
    font-size: 15px;
  }

  .input-container {
    padding: 12px 12px 20px;
    /* Ensure input stays visible above keyboard */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
  }

  .container.initial-view .input-container {
    padding: 0 16px;
    position: relative;
  }

  /* Adjust chat container padding when keyboard might be visible */
  .chat-container {
    padding-bottom: 180px;
  }

  .modal-content {
    margin: 20px;
    max-height: calc(100vh - 40px);
  }

  .modal-header,
  .modal-body {
    padding-left: 20px;
    padding-right: 20px;
  }
}
