*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: #f5f0eb;
  color: #2d2d2d;
  margin: 0;
  padding: 0;
  line-height: 1.7;
}
a { color: #1a3a2a; }

/* Header */
header {
  background: #1a3a2a;
  color: white;
  padding: 2rem 1rem 0;
  text-align: center;
}
header h1 { margin: 0 0 1rem; font-size: 2rem; letter-spacing: 0.02em; }
header a  { color: white; text-decoration: none; }
header a:hover { text-decoration: underline; }

/* Nav */
nav {
  display: flex;
  justify-content: center;
  gap: 0;
  border-top: 1px solid rgba(255,255,255,0.15);
}
nav a {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  font-family: Arial, sans-serif;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
nav a:hover, nav a.active {
  color: white;
  border-bottom-color: #a8d5b5;
}

main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Grade badge */
.grade {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  font-weight: bold;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
}
.grade-a-plus, .grade-a, .grade-a-minus { background: #e8f5e9; color: #1b5e20; }
.grade-b-plus                           { background: #e1f5fe; color: #01579b; }
.grade-b                                { background: #e8eaf6; color: #283593; }
.grade-b-minus                          { background: #fff8e1; color: #f57f17; }
.grade-c-plus, .grade-c, .grade-c-minus { background: #fff3e0; color: #e65100; }
.grade-d, .grade-f                      { background: #ffebee; color: #b71c1c; }

/* ── Index filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
  align-items: center;
}
.search-wrap { flex: 1 1 220px; }
#search {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border: 1px solid #d0c8bc;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: Arial, sans-serif;
  background: white;
}
#search:focus { outline: none; border-color: #1a3a2a; box-shadow: 0 0 0 2px rgba(26,58,42,0.15); }
.filter-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter-controls select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0c8bc;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: Arial, sans-serif;
  background: white;
  cursor: pointer;
}
.filter-controls select:focus { outline: none; border-color: #1a3a2a; }
.stats { font-size: 0.88rem; color: #888; margin-bottom: 1rem; font-style: italic; }
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: #aaa;
  font-style: italic;
}

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 1.5rem;
}
.book-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s, box-shadow 0.18s;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}
.book-card img { width: 100%; height: 230px; object-fit: cover; display: block; }
.no-cover {
  width: 100%; height: 230px;
  background: #ddd5c5;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: #666;
  text-align: center; padding: 1rem; font-style: italic;
}
.card-body {
  padding: 0.9rem 1rem 1rem;
  flex: 1; display: flex; flex-direction: column;
}
.card-title  { font-weight: bold; font-size: 0.92rem; margin: 0 0 0.2rem; }
.card-author { font-size: 0.82rem; color: #777; margin: 0; padding-bottom: 0.5rem; flex: 1; }
.card-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: #999;
  border-top: 1px solid #f0ebe3;
  padding-top: 0.6rem; margin-top: 0.3rem;
}

/* Book detail */
.back-link {
  display: inline-flex; align-items: center; gap: 0.3rem;
  text-decoration: none; color: #1a3a2a;
  font-size: 0.9rem; margin-bottom: 1.5rem;
  font-family: Arial, sans-serif;
}
.back-link:hover { text-decoration: underline; }
.book-detail {
  background: white; border-radius: 10px;
  padding: 2rem; box-shadow: 0 2px 10px rgba(0,0,0,0.09);
}
.book-header { display: flex; gap: 2rem; margin-bottom: 2rem; }
.book-cover img {
  width: 160px; border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22);
  display: block;
}
.book-cover .no-cover { width: 160px; height: 230px; border-radius: 5px; }
.book-info { flex: 1; }
.book-info h1 { margin: 0 0 0.3rem; font-size: 1.7rem; line-height: 1.25; }
.book-info .author { font-size: 1rem; color: #666; margin: 0 0 1.2rem; font-style: italic; }
.book-meta { display: flex; gap: 2rem; flex-wrap: wrap; }
.meta-item { display: flex; flex-direction: column; gap: 0.2rem; }
.meta-label {
  font-family: Arial, sans-serif; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: #aaa;
}
.buy-buttons { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.2rem; }
.btn {
  display: inline-block; padding: 0.55rem 1.1rem;
  border-radius: 6px; text-decoration: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.85rem; font-weight: bold; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-amazon  { background: #ff9900; color: #111; }
.btn-audible { background: #f28c00; color: white; }
.section { margin-top: 2rem; }
.section h2 {
  font-size: 1.1rem;
  border-bottom: 2px solid #ede8e0;
  padding-bottom: 0.4rem; margin-bottom: 0.9rem;
}
.review-text      { font-size: 1rem;    line-height: 1.85; margin: 0; }
.description-text { font-size: 0.95rem; line-height: 1.8;  margin: 0; color: #444; }

/* Lists page */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.list-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.09);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.18s, box-shadow 0.18s;
}
.list-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.13);
}
.list-card h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.list-card p  { margin: 0; font-size: 0.88rem; color: #777; font-style: italic; }
.list-card .list-count { font-size: 0.8rem; color: #aaa; margin-top: 0.8rem; font-family: Arial, sans-serif; }

/* List detail */
.list-detail {
  background: white; border-radius: 10px;
  padding: 2rem; box-shadow: 0 2px 10px rgba(0,0,0,0.09);
}
.list-detail h1 { margin: 0 0 0.5rem; font-size: 1.8rem; }
.list-detail .list-desc { color: #666; font-style: italic; margin: 0 0 2rem; }
.list-entries { list-style: none; padding: 0; margin: 0; }
.list-entry {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
  padding: 1.2rem 0;
  border-bottom: 1px solid #ede8e0;
}
.list-entry:last-child { border-bottom: none; }
.entry-rank {
  font-size: 1.8rem;
  font-weight: bold;
  color: #d4c9b8;
  font-family: Georgia, serif;
  min-width: 2.5rem;
  text-align: right;
  line-height: 1;
  padding-top: 0.1rem;
}
.entry-cover img {
  width: 70px;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  display: block;
}
.entry-cover .no-cover {
  width: 70px; height: 100px;
  background: #ddd5c5;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; color: #888;
  text-align: center; padding: 0.4rem; font-style: italic;
}
.entry-info { flex: 1; }
.entry-info h3 { margin: 0 0 0.15rem; font-size: 1rem; }
.entry-info h3 a { color: #1a3a2a; text-decoration: none; }
.entry-info h3 a:hover { text-decoration: underline; }
.entry-author { font-size: 0.85rem; color: #888; margin: 0 0 0.5rem; font-style: italic; }
.entry-note { font-size: 0.9rem; color: #444; margin: 0; line-height: 1.6; }
.entry-grade { margin-top: 0.5rem; }

footer {
  text-align: center; padding: 2rem 1rem;
  color: #aaa; font-size: 0.82rem;
  font-family: Arial, sans-serif;
  border-top: 1px solid #e0d8cd; margin-top: 2rem;
}
footer a { color: #888; }

@media (max-width: 640px) {
  header h1 { font-size: 1.5rem; }
  nav a { padding: 0.55rem 0.9rem; font-size: 0.8rem; }
  main { padding: 1.5rem 1rem; }
  .book-detail, .list-detail { padding: 1.2rem; }
  .book-header { flex-direction: column; }
  .book-cover { flex: none; }
  .book-cover img, .book-cover .no-cover { width: 130px; }
  .entry-rank { font-size: 1.3rem; min-width: 2rem; }
}
