:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --ok: #2e7d32;
  --error: #c62828;
  --border: #e6e6e0;
  --card-bg: #ffffff;
  --max-width: 960px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

#search {
  display: block;
  width: 100%;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1.1rem;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--fg);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 4px rgba(26, 26, 26, 0.06);
}

.hint {
  margin: 1rem 0;
  color: var(--muted);
  font-size: 1rem;
}

.hint--error { color: var(--error); }
.hint--loading { color: var(--fg); }

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.55rem;
  vertical-align: -0.15em;
  border: 2px solid #d8d8d2;
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#results,
#books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 520px) {
  #results,
  #books { grid-template-columns: 1fr; }
}

.card {
  display: block;
  padding: 0.85rem;
  color: inherit;
  text-decoration: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #d4d4ca;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
}

.card__cover,
.card__tile {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  object-fit: cover;
}

.card__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.card__title {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.card__authors {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.35;
}

.card__year {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.back {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 1rem;
}

.back:hover { color: var(--fg); }

.book {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 640px) {
  .book { grid-template-columns: 1fr; }
}

.book__cover-wrap { width: 100%; }

.book__cover,
.book__tile {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  object-fit: cover;
}

.book__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.book__info { min-width: 0; }

.book__title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.book__authors {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--fg);
}

.book__meta {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.book__description {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.book__description--empty {
  color: var(--muted);
  font-style: italic;
}

.tropes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.trope {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  background: #f0f0ea;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

a.trope:hover {
  background: #e6e6dd;
  border-color: #d4d4ca;
}
