:root {
  --primary-color: #3b82f6;
  --primary-color-hover: #2563eb;
  --secondary-color: #f1f5f9;
  --background-color: #f8fafc;
  --text-color: #334155;
  --border-color: #cbd5e1;
  --white: #ffffff;
  --shadow-color: rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

#root {
  width: 100%;
  max-width: 600px;
}

.app-container {
  background-color: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 24px var(--shadow-color);
  padding: 2rem;
  transition: all 0.3s ease-in-out;
  overflow: hidden;
}

.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.app-header h1 {
  font-size: 2.25rem;
  color: var(--primary-color);
}

.app-header p {
  color: #64748b;
  margin-top: 0.5rem;
}

.form-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'Nunito', sans-serif;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  background-color: var(--primary-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn:hover:not(:disabled) {
  background-color: var(--primary-color-hover);
}

.btn:disabled {
  background-color: #93c5fd;
  cursor: not-allowed;
}

.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
  gap: 1rem;
}

.loader {
  border: 4px solid var(--secondary-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-container p {
  font-weight: 700;
  color: var(--primary-color);
}

.story-container {
  animation: fadeIn 0.5s ease-in-out;
}

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

.story-image {
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  background-color: var(--secondary-color);
  min-height: 200px;
}

.story-text {
  font-size: 1.125rem;
  line-height: 1.8;
  white-space: pre-wrap; /* Preserve line breaks from the API response */
  margin-bottom: 1.5rem;
}

.error-message {
  color: #ef4444;
  background-color: #fee2e2;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  margin: 1rem 0;
}

.btn-secondary {
  background-color: #64748b;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #475569;
}
