:root {
  --cream: #fefdf8;
  --paper: #f9f3e3;
  --warm-paper: #fef6e4;
  --blue-accent: #2f407a;
  --orange-accent: #e07b39;
  --coral: #ff6b6b;
  --dark-text: #3d2c1e;
  --grid-line: #e8dcc8;
  --shadow: rgba(61, 44, 30, 0.15);
}

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

body {
  font-family: 'Handlee', cursive;
  background: linear-gradient(135deg, #fef6e4 0%, #f5ebe0 50%, #fae8d4 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.font-caveat {
  font-family: 'Caveat', cursive;
}

.font-handlee {
  font-family: 'Handlee', cursive;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

/* Landing Page */
.landing-content {
  text-align: center;
  max-width: 600px;
  width: 100%;
  animation: fadeIn 0.8s ease-out;
}

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

.title-container {
  margin-bottom: 10px;
}

.main-title {
  font-size: 3.5rem;
  color: var(--dark-text);
  text-shadow: 2px 2px 4px var(--shadow);
  line-height: 1.1;
}

.title-emoji {
  font-size: 2.5rem;
  display: block;
  margin-top: 8px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.subtitle {
  font-size: 1.3rem;
  color: #6b5344;
  margin-bottom: 30px;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 18px 24px;
  font-size: 1.2rem;
  border: 3px solid var(--orange-accent);
  border-radius: 50px;
  background: var(--cream);
  color: var(--dark-text);
  outline: none;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--shadow);
}

.search-input:focus {
  border-color: var(--coral);
  transform: scale(1.02);
}

.search-input::placeholder {
  color: #a89080;
}

.generate-btn {
  padding: 16px 40px;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--orange-accent), var(--coral));
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(224, 123, 57, 0.4);
}

.generate-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 25px rgba(224, 123, 57, 0.5);
}

.generate-btn:active {
  transform: translateY(0);
}

.error-message {
  color: var(--coral);
  margin-top: 15px;
  font-size: 1.1rem;
}

.examples {
  margin-top: 40px;
}

.examples-label {
  color: #8b7355;
  margin-bottom: 12px;
}

.example-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.example-pill {
  padding: 8px 18px;
  background: var(--warm-paper);
  border: 2px solid var(--grid-line);
  border-radius: 25px;
  color: var(--blue-accent);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.example-pill:hover {
  background: var(--blue-accent);
  color: white;
  border-color: var(--blue-accent);
  transform: translateY(-2px);
}

.landing-footer {
  position: absolute;
  bottom: 20px;
}

.landing-footer a {
  color: #8b7355;
  text-decoration: none;
  transition: color 0.2s;
}

.landing-footer a:hover {
  color: var(--orange-accent);
}

/* Loading Animation */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-book {
  width: 120px;
  height: 90px;
  position: relative;
  perspective: 800px;
}

.book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  width: 12px;
  height: 100%;
  background: var(--blue-accent);
  transform: translateX(-50%);
  border-radius: 2px;
  z-index: 5;
}

.loading-book .page {
  position: absolute;
  width: 54px;
  height: 85px;
  background: var(--cream);
  border: 1px solid var(--grid-line);
  border-radius: 0 5px 5px 0;
  transform-origin: left center;
  left: 50%;
  top: 2.5px;
}

.page-1 { animation: flip 1.5s infinite ease-in-out; z-index: 3; }
.page-2 { animation: flip 1.5s infinite ease-in-out 0.3s; z-index: 2; }
.page-3 { animation: flip 1.5s infinite ease-in-out 0.6s; z-index: 1; }

@keyframes flip {
  0%, 40% { transform: rotateY(0deg); }
  60%, 100% { transform: rotateY(-180deg); }
}

.loading-text {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Guidebook */
.guidebook-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 700px;
  animation: fadeIn 0.5s ease-out;
}

.book {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 3/4;
  background: var(--cream);
  border-radius: 5px 15px 15px 5px;
  box-shadow: 
    -8px 0 20px var(--shadow),
    0 10px 30px var(--shadow),
    inset -2px 0 5px rgba(0,0,0,0.05);
  overflow: hidden;
  transition: transform 0.3s ease;
}

.book.flipping {
  transform: scale(0.98);
}

.book-binding {
  position: absolute;
  left: 0;
  top: 0;
  width: 25px;
  height: 100%;
  background: linear-gradient(90deg, var(--blue-accent) 0%, #3a4f8f 50%, var(--blue-accent) 100%);
  box-shadow: 2px 0 10px var(--shadow);
  z-index: 10;
}

.book-binding::before {
  content: '';
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 8px;
  width: 3px;
  background: linear-gradient(to bottom, 
    var(--orange-accent) 0%, 
    var(--orange-accent) 10%,
    transparent 10%,
    transparent 20%,
    var(--orange-accent) 20%,
    var(--orange-accent) 30%,
    transparent 30%,
    transparent 40%,
    var(--orange-accent) 40%,
    var(--orange-accent) 50%,
    transparent 50%,
    transparent 60%,
    var(--orange-accent) 60%,
    var(--orange-accent) 70%,
    transparent 70%,
    transparent 80%,
    var(--orange-accent) 80%,
    var(--orange-accent) 90%,
    transparent 90%
  );
}

.book-content {
  position: absolute;
  left: 25px;
  right: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
}

/* Book Pages */
.book-page {
  min-height: 100%;
  padding: 25px 20px;
  background: 
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--cream);
  background-size: 25px 25px;
}

/* Cover Page */
.cover-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--warm-paper);
}

.checkered-border {
  position: absolute;
  inset: 10px;
  border: 15px solid transparent;
  background: 
    linear-gradient(var(--warm-paper), var(--warm-paper)) padding-box,
    repeating-conic-gradient(var(--blue-accent) 0% 25%, var(--orange-accent) 25% 50%) border-box;
  background-size: 100% 100%, 30px 30px;
  pointer-events: none;
}

.cover-content {
  text-align: center;
  z-index: 1;
}

.cover-title {
  font-size: 2.5rem;
  color: var(--dark-text);
  margin-bottom: 20px;
  text-shadow: 1px 1px 2px var(--shadow);
}

.cover-image {
  width: 180px;
  height: 180px;
  border-radius: 20px;
  box-shadow: 0 5px 20px var(--shadow);
}

.decorative-stickers {
  position: absolute;
  font-size: 1.8rem;
}

.decorative-stickers.top-left {
  top: 30px;
  left: 30px;
}

.decorative-stickers.bottom-right {
  bottom: 30px;
  right: 30px;
}

.sticker {
  display: inline-block;
  margin: 5px;
  animation: float 3s ease-in-out infinite;
}

.sticker:nth-child(2) {
  animation-delay: 0.5s;
}

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

/* Ingredients Page */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.servings-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warm-paper);
  padding: 8px 15px;
  border-radius: 25px;
  border: 2px solid var(--grid-line);
}

.servings-btn {
  width: 28px;
  height: 28px;
  border: 2px solid var(--orange-accent);
  border-radius: 50%;
  background: white;
  color: var(--orange-accent);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.servings-btn:hover {
  background: var(--orange-accent);
  color: white;
}

.servings-value {
  font-size: 1.3rem;
  min-width: 25px;
  text-align: center;
  color: var(--dark-text);
}

.ingredients-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ingredient-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.5);
  border-radius: 12px;
  transition: transform 0.2s;
}

.ingredient-item:hover {
  transform: translateX(5px);
}

.ingredient-sticker {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  box-shadow: 2px 2px 8px var(--shadow);
  flex-shrink: 0;
}

/* Checkbox Styles */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
}

.checkbox-container input {
  display: none;
}

.checkmark {
  width: 22px;
  height: 22px;
  border: 2px solid var(--orange-accent);
  border-radius: 5px;
  position: relative;
  flex-shrink: 0;
  transition: all 0.2s;
}

.checkbox-container input:checked + .checkmark {
  background: var(--orange-accent);
}

.checkbox-container input:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
}

.checkbox-label {
  color: var(--dark-text);
  line-height: 1.3;
}

.checkbox-container input:checked ~ .checkbox-label {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Steps Page */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.step-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 15px;
  background: rgba(255,255,255,0.6);
  border-radius: 15px;
  border-left: 4px solid var(--orange-accent);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-number {
  width: 35px;
  height: 35px;
  background: var(--blue-accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.step-sticker {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  box-shadow: 2px 2px 8px var(--shadow);
}

.step-text {
  flex: 1;
  min-width: 150px;
  color: var(--dark-text);
  line-height: 1.5;
}

/* Timer Widget */
.timer-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px;
  background: var(--warm-paper);
  border-radius: 20px;
  border: 2px solid var(--coral);
  width: 100%;
  margin-top: 10px;
}

.timer-label {
  color: #8b7355;
  font-size: 0.9rem;
}

.timer-display {
  color: var(--coral);
  flex: 1;
  font-weight: bold;
}

.timer-controls {
  display: flex;
  gap: 5px;
}

.timer-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s;
}

.timer-btn:hover {
  transform: scale(1.1);
}

/* Tips Page */
.tips-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tip-item {
  display: flex;
  gap: 15px;
  padding: 15px;
  background: linear-gradient(135deg, rgba(224,123,57,0.1), rgba(255,107,107,0.1));
  border-radius: 15px;
  align-items: flex-start;
}

.tip-sticker {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.tip-item p {
  color: var(--dark-text);
  line-height: 1.5;
}

/* End Page */
.end-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.end-content {
  text-align: center;
}

.end-decorations {
  font-size: 2rem;
  margin: 20px 0 30px;
  display: flex;
  justify-content: center;
  gap: 15px;
}

.end-decorations span {
  animation: wiggle 1s ease-in-out infinite;
}

.end-decorations span:nth-child(2) { animation-delay: 0.1s; }
.end-decorations span:nth-child(3) { animation-delay: 0.2s; }
.end-decorations span:nth-child(4) { animation-delay: 0.3s; }

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

.end-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.action-btn {
  padding: 12px 25px;
  border: none;
  border-radius: 25px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.save-btn {
  background: var(--blue-accent);
  color: white;
}

.new-btn {
  background: var(--orange-accent);
  color: white;
}

.action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px var(--shadow);
}

.berrry-link {
  color: #8b7355;
  text-decoration: none;
  transition: color 0.2s;
}

.berrry-link:hover {
  color: var(--coral);
}

/* Navigation */
.navigation {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-btn {
  padding: 12px 25px;
  background: var(--warm-paper);
  border: 2px solid var(--grid-line);
  border-radius: 25px;
  color: var(--dark-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--blue-accent);
  color: white;
  border-color: var(--blue-accent);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-indicator {
  color: #8b7355;
}

/* Saved Recipes Sidebar */
.saved-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 250px;
  background: var(--cream);
  box-shadow: 5px 0 20px var(--shadow);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.saved-sidebar.open {
  transform: translateX(0);
}

.sidebar-toggle {
  position: absolute;
  right: -50px;
  top: 20px;
  width: 45px;
  height: 45px;
  background: var(--blue-accent);
  color: white;
  border: none;
  border-radius: 0 10px 10px 0;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-toggle:hover {
  background: var(--orange-accent);
}

.sidebar-content {
  padding: 25px 20px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-content h3 {
  color: var(--dark-text);
  margin-bottom: 15px;
}

.saved-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--warm-paper);
  border-radius: 10px;
}

.saved-name {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  color: var(--blue-accent);
  cursor: pointer;
  font-family: 'Handlee', cursive;
  font-size: 1rem;
}

.saved-name:hover {
  text-decoration: underline;
}

.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.delete-btn:hover {
  opacity: 1;
}

/* Sticker Images */
.sticker-image {
  object-fit: cover;
  transition: opacity 0.3s;
}

.sticker-image.loading {
  opacity: 0.3;
}

.sticker-image.loaded {
  opacity: 1;
}

.sticker-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--warm-paper);
  border-radius: 10px;
  font-size: 2rem;
}

/* Responsive */
@media (max-width: 600px) {
  .main-title {
    font-size: 2.5rem;
  }
  
  .title-emoji {
    font-size: 2rem;
  }
  
  .subtitle {
    font-size: 1.1rem;
  }
  
  .search-input {
    padding: 14px 20px;
    font-size: 1rem;
  }
  
  .generate-btn {
    padding: 14px 30px;
    font-size: 1.3rem;
  }
  
  .example-pill {
    font-size: 0.85rem;
    padding: 6px 14px;
  }
  
  .book {
    max-width: 100%;
  }
  
  .book-page {
    padding: 20px 15px;
  }
  
  .cover-title {
    font-size: 2rem;
  }
  
  .cover-image {
    width: 140px;
    height: 140px;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .ingredient-sticker {
    width: 40px;
    height: 40px;
  }
  
  .step-sticker {
    width: 50px;
    height: 50px;
  }
  
  .navigation {
    gap: 10px;
  }
  
  .nav-btn {
    padding: 10px 18px;
    font-size: 1rem;
  }
  
  .saved-sidebar {
    width: 100%;
    max-width: 280px;
  }
  
  .sidebar-toggle {
    right: -45px;
    width: 40px;
    height: 40px;
  }
}