body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  margin: 0;
  padding: 0;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  align-items: flex-start;
}

.app {
  width: 100%;
  max-width: 1100px;
  padding: 24px;
}

h1 {
  margin-top: 0;
  font-size: 2rem;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end; /* align bottoms of controls + button */
  justify-content: center;
  margin-bottom: 16px;
  background: #020617;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #1f2937;
}

.controls label {
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.controls input,
.controls select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  min-width: 160px;
}

button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  background: #FFEE8C; /* Figma pastel yellow */
  color: #1f2937;
  transition: transform 0.05s ease, box-shadow 0.1s ease, background 0.1s ease;
  margin-left: 12px;       /* nudge to the right of the last select */
  align-self: flex-end;    /* align bottom in the row */
}

button:hover {
  background: #f7df6f;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(255, 238, 140, 0.4);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.status {
  text-align: center;
  min-height: 1.2em;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #9ca3af;
}

.debug-panel {
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: #9ca3af;
}

.debug-panel summary {
  cursor: pointer;
  outline: none;
}

#debugLog {
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  background: #020617;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #111827;
  margin-top: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: #020617;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #111827;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  position: relative;
}

.image-wrapper {
  position: relative;
  overflow: hidden;
  background: #020617;
}

/* Show whole image, proportional, with landscape sizing */
.image-wrapper img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  margin: 0 auto;
}

.quote-block {
  background: #020617;
  border-top: 1px solid #111827;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #f9fafb;
}

.quote-block .text {
  font-style: italic;
}

.quote-block .author {
  margin-top: 6px;
  font-size: 0.8rem;
  opacity: 0.9;
  text-align: right;
}

.card-footer {
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-footer a {
  color: inherit;
  text-decoration: underline;
}

.source-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.source {
  opacity: 0.9;
}

.categories {
  font-size: 0.75rem;
  opacity: 0.85;
}

.download-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.download-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 500;
}

.download-btn:hover {
  background: #111827;
}

.image-error {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.9));
  color: #fca5a5;
  font-size: 0.9rem;
  text-align: center;
  padding: 8px;
  box-sizing: border-box;
}

.card-error {
  padding: 16px;
  background: #111827;
  color: #fca5a5;
  font-size: 0.9rem;
  text-align: center;
}

.card-error small {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
}

@media (max-width: 600px) {
  .controls {
    align-items: stretch;
  }

  .controls label {
    width: 100%;
  }

  .controls input,
  .controls select {
    width: 100%;
  }
}
