:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1a2a1f;
  --text-muted: #5b6b60;
  --accent: #2d6a4f;
  --accent-soft: #e3f0e8;
  --border: #d8e6dc;
  --shadow: 0 4px 18px rgba(26, 42, 31, 0.08);
  --star: #2d6a4f;
  --star-empty: #d8e6dc;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', -apple-system, system-ui, sans-serif;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f4faf6 0%, var(--bg) 100%);
}

.home-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
.home-link:hover { opacity: 1; }

.site-title {
  margin: 0 0 0.25rem;
  font-size: 2.5rem;
  letter-spacing: -0.5px;
  color: var(--accent);
}
.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-tagline {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin: 2rem 0 1.5rem;
}

.search-input {
  flex: 1 1 260px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.filter-group select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  padding-bottom: 3rem;
}

.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #b6d4c1;
}

.book-cover {
  background: linear-gradient(135deg, #e3f0e8 0%, #b6d4c1 100%);
  border-radius: 6px;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.75rem;
  color: var(--accent);
  font-weight: bold;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  overflow: hidden;
}

.book-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text);
}

.book-author {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.95rem;
}

.book-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stars { letter-spacing: 1px; font-size: 0.95rem; }
.stars .filled { color: var(--star); }
.stars .empty { color: var(--star-empty); }

.genre-tag {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: -apple-system, system-ui, sans-serif;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-style: italic;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.55);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem 2rem 2.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.modal-close:hover { color: var(--accent); }

.modal h2 {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 1.7rem;
}
.modal .author {
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 1rem;
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  margin: 1rem 0 1.25rem;
  font-family: -apple-system, system-ui, sans-serif;
}

.review-text {
  font-size: 1.02rem;
  white-space: pre-wrap;
}

.review-text p { margin: 0 0 1em; }

.favorite-quote {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.75rem 1rem;
  margin: 1.25rem 0 0.5rem;
  font-style: italic;
  color: #1f4030;
  border-radius: 0 6px 6px 0;
}

/* ---- Article view (Medium-style) ---- */
.article-view {
  max-width: 720px;
  padding-top: 1.5rem;
  padding-bottom: 4rem;
}

.article-nav-top {
  margin-bottom: 2rem;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0;
  transition: opacity 0.15s ease;
}
.back-link:hover { opacity: 0.7; }

.article header { margin-bottom: 2rem; }

.article h1 {
  font-size: 2.4rem;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--text);
  letter-spacing: -0.5px;
  font-weight: 600;
}

.article .article-author {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  font-style: italic;
}

.article-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.article-meta-row .stars { font-size: 1.1rem; }

.article-content {
  font-size: 1.18rem;
  line-height: 1.75;
  color: #2a3a30;
  margin-top: 2rem;
}

.article-content p { margin: 0 0 1.5em; }

.article-content h2 {
  font-size: 1.55rem;
  margin: 2.25rem 0 1rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.25px;
}

.article-content h3 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.75rem;
  color: var(--text);
  font-weight: 600;
}

.article-content blockquote {
  border-left: 4px solid var(--accent);
  margin: 1.75rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  color: var(--text);
  font-style: italic;
  font-size: 1.25rem;
  line-height: 1.55;
}

.pull-quote {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: #1f4030;
  border-radius: 0 6px 6px 0;
  font-size: 1.15rem;
  line-height: 1.6;
}
.pull-quote .quote-label {
  display: block;
  font-style: normal;
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.article-nav-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  align-items: stretch;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
  background: var(--surface);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  min-width: 0;
}
.nav-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.nav-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-button.center {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 500;
  justify-content: center;
}
.nav-button.center:hover { opacity: 0.9; color: #fff; }
.nav-button:last-child { justify-content: flex-end; text-align: right; }

/* ---- Mobile (single consolidated block) ---- */
@media (max-width: 700px) {
  .container { padding: 0 1rem; }

  /* Header */
  .site-header { padding: 1.75rem 0 1.25rem; }
  .site-title { font-size: 1.7rem; }
  .site-tagline { font-size: 0.95rem; }
  .home-link {
    padding: 0.5rem 0;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  /* Controls - stack search full-width, filters in a 2-col grid */
  .controls {
    margin: 1.25rem 0 1.25rem;
    gap: 0.6rem;
  }
  .search-input {
    flex: 1 1 100%;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
  }
  .filter-group {
    flex: 1 1 calc(50% - 0.3rem);
    justify-content: space-between;
    font-size: 0.85rem;
  }
  .filter-group select {
    flex: 1;
    min-width: 0;
    padding: 0.65rem 0.5rem;
    font-size: 1rem;
  }

  /* Book grid: 2 columns on phones */
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    padding-bottom: 2rem;
  }
  .book-card {
    padding: 0.75rem 0.75rem 0.9rem;
    gap: 0.35rem;
  }
  .book-cover {
    font-size: 0.78rem;
    padding: 0.5rem;
    margin-bottom: 0.35rem;
  }
  .book-title { font-size: 0.95rem; line-height: 1.25; }
  .book-author { font-size: 0.82rem; }
  .book-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.78rem;
  }
  .stars { font-size: 0.85rem; }
  .genre-tag { font-size: 0.7rem; }

  /* Modal */
  .modal { padding: 0.75rem; }
  .modal-content {
    padding: 1.5rem 1.1rem 1.75rem;
    max-height: 92vh;
    border-radius: 12px;
  }
  .modal h2 { font-size: 1.4rem; }
  .modal-close {
    font-size: 2rem;
    padding: 0.5rem 0.75rem;
    top: 0.25rem;
    right: 0.5rem;
    min-width: 44px;
    min-height: 44px;
  }
  .review-meta {
    gap: 0.4rem 1rem;
    font-size: 0.85rem;
  }
  .full-breakdown-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.85rem 1rem;
  }

  /* Article view */
  .article-view { padding-top: 1rem; padding-bottom: 2.5rem; }
  .article-nav-top { margin-bottom: 1.25rem; }
  .back-link { padding: 0.6rem 0; font-size: 1rem; }
  .article header { margin-bottom: 1.5rem; }
  .article h1 { font-size: 1.8rem; }
  .article .article-author { font-size: 1rem; margin-bottom: 1rem; }
  .article-meta-row {
    font-size: 0.85rem;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
  }
  .article-content {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-top: 1.5rem;
  }
  .article-content h2 { font-size: 1.3rem; margin: 1.75rem 0 0.75rem; }
  .article-content h3 { font-size: 1.1rem; }
  .article-content blockquote { font-size: 1.1rem; padding-left: 1rem; }
  .pull-quote { font-size: 1rem; padding: 1rem 1.1rem; }
  .article-nav-bottom {
    grid-template-columns: 1fr;
    margin-top: 2rem;
    padding-top: 1.5rem;
  }
  .nav-button {
    padding: 0.95rem 1rem;
    font-size: 0.95rem;
  }
  .nav-button:last-child { justify-content: flex-start; text-align: left; }
}

/* Very small screens - single book column */
@media (max-width: 380px) {
  .book-grid { grid-template-columns: 1fr; }
  .filter-group { flex: 1 1 100%; }
}

/* ---- Modal "See full breakdown" button ---- */
.full-breakdown-btn {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.7rem 1.4rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s ease;
}
.full-breakdown-btn:hover { opacity: 0.88; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  font-family: -apple-system, system-ui, sans-serif;
}
.site-footer code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Blog posts reuse .book-card but skip the tall cover and add an excerpt. */
.post-card .post-cover {
  aspect-ratio: auto;
  padding: 1rem 0.9rem;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}
.post-card .post-excerpt {
  margin: 0.25rem 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.post-figure {
  margin: 1.75rem 0;
  text-align: center;
}
.post-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.post-figure figcaption {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}

