/* ============================================
   GESCHICHTENGENERATOR - Main Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #f59e0b;
  --color-primary-dark: #d97706;
  --color-primary-light: #fbbf24;
  --color-secondary: #6366f1;
  --color-secondary-light: #818cf8;
  --color-accent: #10b981;
  --color-accent-light: #34d399;
  --color-magic: #ec4899;
  --color-magic-light: #f472b6;

  --color-bg: #fef7ed;
  --color-bg-warm: #fff8f0;
  --color-bg-card: #ffffff;
  --color-text: #3e2723;
  --color-text-light: #78716c;
  --color-text-muted: #a8a29e;
  --color-border: #e7e5e4;
  --color-border-light: #f5f5f4;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 30px rgba(245,158,11,0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --font-display: 'Quicksand', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --font-handwriting: 'Caveat', cursive;

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* --- Animated Background --- */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-element {
  position: absolute;
  animation: float var(--duration, 8s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0.12;
}

.floating-element.star {
  font-size: 2rem;
  color: var(--color-primary);
}

.floating-element.cloud {
  font-size: 3.5rem;
  color: var(--color-secondary-light);
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(5deg); }
  50% { transform: translateY(-10px) rotate(-3deg); }
  75% { transform: translateY(-25px) rotate(3deg); }
}

/* --- App Container --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 2.5rem;
  animation: wiggle 3s ease-in-out infinite;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.logo-highlight {
  background: linear-gradient(135deg, var(--color-primary), var(--color-magic));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-family: var(--font-handwriting);
  font-size: 1.3rem;
  color: var(--color-text-light);
  margin-top: 0.25rem;
}

/* --- Progress Bar --- */
.progress-bar {
  margin-bottom: 2rem;
}

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  z-index: 1;
}

.step-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  transition: var(--transition);
  border: 3px solid transparent;
}

.progress-step.active .step-circle {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  border-color: var(--color-primary-light);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

.progress-step.completed .step-circle {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent-light);
}

.step-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.progress-step.active .step-label,
.progress-step.completed .step-label {
  color: var(--color-text);
}

.progress-line {
  width: 60px;
  height: 3px;
  background: var(--color-border);
  border-radius: 2px;
  margin-bottom: 1.2rem;
  transition: var(--transition);
}

.progress-line.filled {
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
}

/* --- Wizard Steps --- */
.wizard-container {
  flex: 1;
}

.wizard-step {
  display: none;
  animation: fadeSlideIn 0.4s ease-out;
}

.wizard-step.active {
  display: block;
}

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

/* --- Step Card --- */
.step-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border-light);
}

.step-header {
  text-align: center;
  margin-bottom: 2rem;
}

.step-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.step-header h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.step-header p {
  color: var(--color-text-light);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* --- Form Groups --- */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.label-icon {
  font-size: 1.1rem;
}

.optional {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg-warm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  outline: none;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  background: white;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2378716c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.input-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.input-hint kbd {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  font-family: var(--font-body);
  background: var(--color-border-light);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* --- Tag Input --- */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-warm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: text;
  transition: var(--transition);
  min-height: 48px;
}

.tag-input-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
  background: white;
}

.tags-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-input-container input {
  flex: 1;
  min-width: 120px;
  padding: 0.3rem 0.25rem;
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
}

.tag-input-container input:focus {
  box-shadow: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.5rem 0.3rem 0.7rem;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
  animation: tagPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

@keyframes tagPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: none;
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.tag-remove:hover {
  background: rgba(255,255,255,0.5);
}

/* --- Genre Grid --- */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.genre-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.75rem;
  background: var(--color-bg-warm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.genre-card:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.genre-card.selected {
  border-color: var(--color-primary);
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(245,158,11,0.15));
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.genre-card .genre-emoji {
  font-size: 2rem;
}

.genre-card .genre-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text);
}

.genre-card .genre-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* --- Story Length Options --- */
.length-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.length-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  cursor: pointer;
  transition: all 0.2s;
}

.length-option:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.length-option.selected {
  border-color: var(--color-primary);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.length-option .length-emoji {
  font-size: 1.5rem;
}

.length-option .length-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
}

.length-option .length-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Field Description --- */
.field-description {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: -0.25rem 0 0.75rem;
}

/* --- Art Style Grid --- */
.art-style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}

.art-style-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.85rem 0.6rem;
  background: var(--color-bg-warm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.art-style-card:hover {
  border-color: var(--color-secondary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.art-style-card.selected {
  border-color: var(--color-secondary);
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(99,102,241,0.13));
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.art-style-card .style-emoji {
  font-size: 1.8rem;
}

.art-style-card .style-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text);
}

.art-style-card .style-desc {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* --- Theme & Element Suggestions --- */
.theme-suggestions,
.element-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.suggestion-chip {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  background: var(--color-bg-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.suggestion-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: rgba(245, 158, 11, 0.08);
}

/* --- Image Count Selector --- */
.image-count-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.image-count-selector input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-primary));
  border-radius: 3px;
  border: none;
  padding: 0;
}

.image-count-selector input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.image-count-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary-dark);
  min-width: 70px;
  text-align: center;
}

/* --- Summary Card --- */
.summary-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.05), rgba(99,102,241,0.05));
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-top: 0.5rem;
}

.summary-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.summary-content {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.9rem;
}

.summary-label {
  font-weight: 600;
  color: var(--color-text-light);
}

.summary-value {
  color: var(--color-text);
}

/* --- Buttons --- */
.step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.8rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-bg-warm);
  color: var(--color-text-light);
  border: 2px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.btn-magic {
  background: linear-gradient(135deg, var(--color-primary), var(--color-magic), var(--color-secondary));
  background-size: 200% 200%;
  color: white;
  font-size: 1.1rem;
  padding: 1rem 2.5rem;
  box-shadow: 0 6px 25px rgba(236, 72, 153, 0.3);
  animation: shimmer 3s ease infinite;
}

.btn-magic:hover {
  box-shadow: 0 8px 35px rgba(236, 72, 153, 0.4);
  transform: translateY(-2px);
}

.btn-magic:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.btn-arrow {
  font-size: 1.2rem;
}

.btn-sparkle {
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

/* --- Loading Screen --- */
.loading-screen {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.book-animation {
  width: 100px;
  height: 80px;
  margin: 0 auto 2rem;
  position: relative;
  perspective: 600px;
}

.book-page {
  position: absolute;
  width: 50px;
  height: 70px;
  border-radius: 2px 6px 6px 2px;
  top: 5px;
}

.page-left {
  left: 0;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-right: 1px solid #d97706;
  transform: rotateY(0deg);
  transform-origin: right;
}

.page-right {
  right: 0;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-left: 1px solid #d97706;
}

.page-flip {
  left: 0;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  transform-origin: right;
  animation: pageFlip 1.5s ease-in-out infinite;
}

@keyframes pageFlip {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(-180deg); }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.loading-subtitle {
  color: var(--color-text-light);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.loading-progress {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: var(--color-border-light);
  border-radius: 4px;
  margin: 0 auto 1rem;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-magic), var(--color-secondary));
  background-size: 200% 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease;
  animation: loadingGradient 2s linear infinite;
}

@keyframes loadingGradient {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

.loading-status {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* --- Story Display --- */
.story-display {
  animation: fadeSlideIn 0.6s ease-out;
}

.story-header {
  text-align: center;
  padding: 2.5rem 2rem 2rem;
  background: linear-gradient(135deg, var(--color-bg-card), rgba(245,158,11,0.05));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--color-border-light);
  border-bottom: none;
}

.title-image-container {
  margin: -2.5rem -2rem 1.5rem -2rem;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  position: relative;
}

.title-image {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.title-image:hover {
  filter: brightness(1.05);
}

.title-image-actions {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.title-image-actions button {
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}

.title-image-actions button:hover {
  background: rgba(0, 0, 0, 0.8);
}

.title-image-loading {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: 0.9rem;
  background: linear-gradient(135deg, rgba(245,158,11,0.05), rgba(236,72,153,0.05));
  animation: imageShimmer 2s ease-in-out infinite;
}

/* --- Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  backdrop-filter: blur(6px);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-download {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}

.lightbox-download:hover {
  background: rgba(255, 255, 255, 0.3);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.story-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.story-meta {
  color: var(--color-text-muted);
  font-family: var(--font-handwriting);
  font-size: 1.1rem;
}

.story-content {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  overflow: hidden;
}

.story-section {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border-light);
}

.story-section:last-child {
  border-bottom: none;
}

.story-section-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--color-text);
  white-space: pre-line;
}

.story-section-image {
  margin: 1rem 0 0.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.story-section-image img {
  width: 100%;
  height: auto;
  display: block;
}

.story-section-image.loading {
  background: linear-gradient(90deg, var(--color-border-light), var(--color-border), var(--color-border-light));
  background-size: 200% 100%;
  animation: imageShimmer 1.5s ease-in-out infinite;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: 0.9rem;
}

@keyframes imageShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.story-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-bottom: 1rem;
}

/* --- Error Display --- */
.error-card {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 2px solid #fca5a5;
}

.error-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
}

.error-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.error-message {
  color: var(--color-text-light);
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 2rem 1rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.privacy-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .app-container {
    padding: 1rem;
  }

  .logo h1 {
    font-size: 1.6rem;
  }

  .step-card {
    padding: 1.5rem 1.25rem;
  }

  .step-header h2 {
    font-size: 1.4rem;
  }

  .genre-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .btn-magic {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
  }

  .step-actions {
    flex-direction: column-reverse;
  }

  .step-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .story-title {
    font-size: 1.5rem;
  }

  .story-section {
    padding: 1.25rem 1rem;
  }

  .progress-line {
    width: 30px;
  }

  .step-label {
    font-size: 0.65rem;
  }
}

/* --- Print Styles --- */
@media print {
  .bg-decorations,
  .app-header,
  .progress-bar,
  .step-actions,
  .story-actions,
  .app-footer,
  .btn,
  .title-image-actions {
    display: none !important;
  }

  .app-container {
    max-width: 100%;
    padding: 0;
  }

  .story-header {
    background: none;
    border: none;
    padding: 1rem 0;
  }

  .story-content {
    border: none;
    box-shadow: none;
  }

  .story-section {
    break-inside: avoid;
    padding: 0.75rem 0;
  }

  .story-section-image {
    break-inside: avoid;
    box-shadow: none;
  }

  .story-title {
    font-size: 1.8rem;
  }

  .story-section-text {
    font-size: 12pt;
    line-height: 1.6;
  }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* --- Validation Shake --- */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.form-group.error input,
.form-group.error .tag-input-container,
.form-group.error textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-group .error-text {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  font-weight: 600;
}

/* --- "Meine Gruppe" Header Button --- */
.btn-group-manage {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.5rem 1.2rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-secondary);
  background: rgba(99, 102, 241, 0.08);
  border: 1.5px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.btn-group-manage:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--color-secondary);
}

/* --- Group Info Bar (Step 1) --- */
.group-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.2rem;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.08), rgba(236, 72, 153, 0.05));
  border: 1.5px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.group-info-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  flex-wrap: wrap;
}

.group-info-separator {
  color: var(--color-text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  transition: var(--transition);
}

.btn-link:hover {
  color: var(--color-secondary-light);
}

/* --- Checkbox List --- */
.checkbox-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.checkbox-actions .btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.9rem;
  background: var(--color-bg-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  text-decoration: none;
  font-size: 0.8rem;
  color: var(--color-text-light);
  transition: var(--transition);
}

.checkbox-actions .btn-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  background: rgba(245, 158, 11, 0.06);
}

.children-checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

.child-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.9rem;
  background: white;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  opacity: 0.75;
}

.child-checkbox-item:hover {
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.1);
  opacity: 1;
}

.child-checkbox-item.checked {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(251, 191, 36, 0.18));
  border: 1.5px solid var(--color-primary);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.15);
  opacity: 1;
}

.child-checkbox-item.checked:hover {
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
}

/* Custom checkbox: hide native */
.child-checkbox-item input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom checkbox: checked state */
.child-checkbox-item input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border-color: var(--color-primary-dark);
}

/* Custom checkbox: checkmark */
.child-checkbox-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.child-checkbox-item .child-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Gender Indicator (Step 1 checkbox list) --- */
.child-gender-indicator {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
}

.child-gender-indicator.gender-m {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
}

.child-gender-indicator.gender-f {
  background: rgba(6, 182, 212, 0.12);
  color: #06b6d4;
}

/* --- Modal Children List --- */
.modal-children-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gender-hint {
  font-size: 0.8rem;
  color: var(--color-secondary);
  font-weight: 600;
  font-family: var(--font-display);
  padding: 0.5rem 0.75rem;
  background: rgba(99, 102, 241, 0.06);
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

.modal-child-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-bg-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-child-row.no-gender {
  border-color: var(--color-primary-light);
  background: rgba(245, 158, 11, 0.04);
}

.modal-child-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-child-gender {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.modal-child-gender-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0.3rem 0.65rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: white;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--color-text-muted);
  line-height: 1;
  white-space: nowrap;
}

.modal-child-gender-btn:hover {
  border-color: var(--color-text-muted);
}

.modal-child-gender-btn.active-m {
  background: #06b6d4;
  border-color: #06b6d4;
  color: white;
  box-shadow: 0 1px 4px rgba(6, 182, 212, 0.3);
}

.modal-child-gender-btn.active-f {
  background: #06b6d4;
  border-color: #06b6d4;
  color: white;
  box-shadow: 0 1px 4px rgba(6, 182, 212, 0.3);
}

.modal-child-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.modal-child-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* --- Educator Tags (read-only display) --- */
.educator-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.educator-tag {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: linear-gradient(135deg, var(--color-secondary-light), var(--color-secondary));
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
}

/* --- No Group Notice --- */
.no-group-notice {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--color-bg-warm);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}

.no-group-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.no-group-notice h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.no-group-notice p {
  color: var(--color-text-light);
  font-size: 0.9rem;
  max-width: 400px;
  margin: 0 auto 1.25rem;
  line-height: 1.5;
}

/* --- Manual Input Fallback --- */
.manual-input-fallback {
  margin-top: 0.5rem;
}

.manual-input-fallback summary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0.75rem;
  transition: var(--transition);
}

.manual-input-fallback summary:hover {
  color: var(--color-text);
}

.manual-input-fallback[open] summary {
  margin-bottom: 1rem;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease-out;
}

.modal-small {
  max-width: 420px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-bg-warm);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-light);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

#groupListView,
#groupEditView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-body {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--color-border-light);
}

.modal-footer-left {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* --- Group Cards (Modal List) --- */
.group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-bg-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.6rem;
  transition: var(--transition);
}

.group-card:hover {
  border-color: var(--color-primary-light);
}

.group-card-info {
  flex: 1;
  min-width: 0;
}

.group-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-card-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.group-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-danger {
  color: #ef4444 !important;
  border-color: #fca5a5 !important;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: #ef4444 !important;
}

/* --- Welcome Overlay --- */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.welcome-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: modalSlideIn 0.3s ease-out;
}

.welcome-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.welcome-card h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.welcome-card p {
  color: var(--color-text-light);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.welcome-card .form-group {
  margin-bottom: 1.25rem;
}

.welcome-card .btn {
  width: 100%;
  justify-content: center;
}

/* --- Print: hide modal and group button --- */
@media print {
  .modal-overlay,
  .btn-group-manage,
  .welcome-overlay {
    display: none !important;
  }
}

/* --- Responsive: modal --- */
@media (max-width: 640px) {
  .modal-content {
    max-height: 95vh;
    border-radius: var(--radius-lg);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-footer-left {
    justify-content: center;
  }

  .modal-footer .btn-primary {
    width: 100%;
    justify-content: center;
  }

  .children-checkbox-list {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  .group-info-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .group-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .group-card-actions {
    width: 100%;
  }

  .group-card-actions .btn {
    flex: 1;
    justify-content: center;
  }
}
