/* Base colors and fonts */
body {
  background-color: #FDFBF7; /* Soft cream/linen */
  color: #3E3B39;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header h1 {
  color: #556B2F; /* Olive green */
  font-weight: 300;
  letter-spacing: 2px;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  width: 100%;
  max-width: 1200px;
  margin-top: 20px;
}

.library-panel {
  flex: 1;
  min-width: 320px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar input,
.toolbar select {
  flex: 1;
  min-width: 0;
}

/* Form Styling */
.form-section {
  background-color: #FFFFFF;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  width: 300px;
  height: fit-content;
  border: 1px solid #E6D5C3;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input, textarea {
  padding: 10px;
  border: 1px solid #D4B499; /* Rotin tone */
  border-radius: 4px;
  background-color: #FDFBF7;
}

button {
  background-color: #E2725B; /* Terracotta */
  color: white;
  border: none;
  padding: 12px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
}

.secondary-btn {
  background-color: #8C7A6B;
  margin-top: 8px;
}

.danger-btn {
  background-color: #b35245;
  margin-top: 8px;
}

.rating-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.star-rating {
  display: flex;
  gap: 4px;
}

.star-btn {
  background: none;
  color: #D4B499;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
  width: 1.2em;
  text-align: center;
}

.spice-btn {
  font-size: 1.2rem;
  width: 1.2em;
}

.star-btn.active,
.star-btn:hover {
  color: #E2725B;
}

.trope-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trope-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.hidden-trope-panel {
  display: none;
}

.trope-toggle {
  background: #FDFBF7;
  color: #3E3B39;
  border: 1px solid #D4B499;
  text-align: left;
  font-weight: 600;
}

.trope-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #E6D5C3;
  border-radius: 999px;
  background: #FFF;
  font-size: 0.9rem;
}

.trope-chip input {
  margin: 0;
}

button:hover {
  background-color: #C15B46;
}

/* Library & Shelves */
#library-container {
  flex-grow: 1;
  min-width: 400px;
}

.genre-title {
  color: #8C7A6B;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.9rem;
  margin-bottom: -15px;
  margin-left: 20px;
}

.shelf-row {
  background-color: #E6D5C3; /* Light wood */
  border-bottom: 15px solid #D4B499; /* Rotin edge */
  margin-bottom: 50px;
  padding: 10px 20px 0 20px;
  display: flex;
  align-items: flex-end; /* Keeps books flat on the shelf */
  gap: 2px;
  min-height: 250px;
}

/* Individual Books */
.book-spine {
  cursor: pointer;
  background-size: cover;
  background-position: center;
  box-shadow: inset 2px 0 5px rgba(255,255,255,0.2), inset -2px 0 4px rgba(0,0,0,0.3);
  border-radius: 2px 3px 3px 2px;
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  font-size: 0.7rem;
  overflow: hidden;
}

.book-spine:hover {
  transform: translateY(-10px);
}

.book-spine.thin { box-shadow: inset 1px 0 2px rgba(255,255,255,0.18), inset -1px 0 2px rgba(0,0,0,0.28); }
.book-spine.medium { box-shadow: inset 2px 0 4px rgba(255,255,255,0.18), inset -2px 0 4px rgba(0,0,0,0.28); }
.book-spine.large { box-shadow: inset 3px 0 5px rgba(255,255,255,0.18), inset -3px 0 5px rgba(0,0,0,0.28); }
.book-spine.xlarge { box-shadow: inset 4px 0 6px rgba(255,255,255,0.18), inset -4px 0 6px rgba(0,0,0,0.28); }

/* Reference Card Modal */
#reference-card,
#edit-book-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(253, 251, 247, 0.8); /* Cream overlay */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.card-content {
  background: #FFF;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  border: 1px solid #E6D5C3;
  width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.edit-content {
  width: 440px;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.rating-pill .icon {
  font-size: 1rem;
  line-height: 1;
}

.cover-preview {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.cover-image {
  width: 100%;
  max-width: 180px;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

#close-card,
#close-editor {
  position: absolute;
  top: 10px; right: 10px;
  background: none;
  color: #3E3B39;
  font-size: 1.5rem;
  padding: 0;
  width: 30px;
}

.empty-state {
  color: #8C7A6B;
  font-style: italic;
}

.hidden {
  display: none !important;
}

#loading-spinner {
  display: none; /* Hidden by default */
  text-align: center;
  padding: 40px;
  font-style: italic;
  color: #666;
}