* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f5fb;
  color: #111827;
}

.app-header {
  padding: 1.5rem 1rem;
  text-align: center;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: white;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.app-header .tagline {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  opacity: 0.9;
}

.mode-switcher {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #e5e7eb;
  border-bottom: 1px solid #d1d5db;
}

.mode-button {
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  border: 1px solid #d1d5db;
}

.mode-button.active {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}

.app-main {
  max-width: 960px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
}

.panel {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
}

.panel.hidden { display: none; }

.panel h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

.panel-intro {
  margin-top: 0.25rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #4b5563;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr);
  gap: 1rem;
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group-inline { justify-content: flex-end; }

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

input[type="text"], select, textarea {
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.teacher-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .teacher-controls { grid-template-columns: 1fr; }
}

.button-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.primary-button {
  background: #1d4ed8;
  color: white;
  border-radius: 999px;
  border: none;
  padding: 0.55rem 1.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.primary-button:disabled { opacity: 0.7; cursor: default; }

.secondary-button {
  background: #ffffff;
  color: #1d4ed8;
  border-radius: 999px;
  border: 1px solid #1d4ed8;
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.status-text {
  font-size: 0.85rem;
  color: #4b5563;
}

.status-text.error { color: #b91c1c; }

.saved-mission {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

.saved-mission h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.saved-mission ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
}

.lesson-summary {
  background: #eff6ff;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid #bfdbfe;
}

.lesson-summary p { margin: 0.2rem 0; }

.chapter-history {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.chapter-meta {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.story-output {
  margin-top: 0.75rem;
  padding: 0.9rem;
  background: #f9fafb;
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.5;
}

.questions-output {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: #ecfdf5;
  border-radius: 0.75rem;
  border: 1px solid #bbf7d0;
  font-size: 0.9rem;
}

.questions-output h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
}

.questions-output ol {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.app-footer {
  text-align: center;
  padding: 1rem 0.5rem 1.5rem;
  font-size: 0.75rem;
  color: #6b7280;
}
