.books-page { max-width: 820px; margin: 0 auto; }

.books-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}
.books-header h1 { font-weight: 300; font-size: 1.7rem; margin: 0; }
.books-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.books-actions button {
  padding: 0.55rem 0.9rem; font-family: inherit; font-size: 0.9rem;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; cursor: pointer;
}
.books-actions button.primary { background: #378ADD; color: white; border-color: #378ADD; font-weight: 600; }
.books-actions button:hover { filter: brightness(1.08); }

.books-filters {
  display: flex; gap: 0.3rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.filter-tab {
  padding: 0.4rem 0.8rem; font-family: inherit; font-size: 0.85rem;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 999px; cursor: pointer;
}
.filter-tab.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter-tab .count { opacity: 0.6; margin-left: 0.3rem; font-size: 0.75rem; }

#books-search {
  display: block; width: 100%;
  padding: 0.55rem 0.7rem;
  margin: 0.5rem 0 0.8rem;
  font-family: inherit; font-size: 0.95rem;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
}

.books-list { display: flex; flex-direction: column; gap: 0.4rem; }
.book-card {
  padding: 0.6rem 0.8rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: flex-start; gap: 0.8rem;
  cursor: pointer;
  transition: border-color 0.12s;
}
.book-card:hover { border-color: #378ADD; }
.book-rating {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: white;
  font-family: 'Georgia', serif;
}
.book-rating.r4 { background: #a8761e; } /* gold */
.book-rating.r3 { background: #1c3b42; } /* deep teal */
.book-rating.r2 { background: #7fa8a0; } /* muted teal */
.book-rating.r1 { background: #b8ab8c; color: #3a2e18; } /* sand */
.book-rating.r0 { background: #8c3a2b; } /* rust — DNF */
.book-rating.wishlist,
.book-rating.reading { background: var(--bg); color: var(--text-muted); border: 1px dashed var(--border); font-size: 0.65rem; letter-spacing: 0.05em; }

.book-body { flex: 1; min-width: 0; }
.book-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.1rem; }
.book-author { font-size: 0.85rem; color: var(--text-muted); }
.book-evidence { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; line-height: 1.35; font-style: italic; }
.book-tags {
  display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.35rem;
}
.book-tag {
  font-size: 0.7rem; padding: 0.05rem 0.4rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted);
}
.book-status-badge {
  font-size: 0.7rem; padding: 0.05rem 0.4rem;
  background: var(--bg); border-radius: 4px; color: var(--text-muted);
  align-self: center;
  font-family: system-ui, sans-serif;
}
.book-status-badge.reading { color: #2ea866; border: 1px solid #2ea866; }
.book-status-badge.wishlist { color: #378ADD; border: 1px solid #378ADD; }

/* Dialog */
.dialog-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 1rem;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.2rem 1.4rem;
  max-width: 460px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  color: var(--text);
}
.dialog.wide { max-width: 640px; }
.dialog h2 { font-weight: 400; margin: 0 0 0.6rem; font-size: 1.2rem; }
.dialog label { display: block; margin-bottom: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }
.dialog label input, .dialog label select, .dialog label textarea {
  display: block; width: 100%; margin-top: 0.2rem;
  padding: 0.45rem 0.6rem; font-family: inherit; font-size: 0.9rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 5px;
}
.dialog-actions { display: flex; gap: 0.4rem; margin-top: 0.8rem; flex-wrap: wrap; }
.dialog-actions button {
  padding: 0.55rem 1rem; font-family: inherit; font-size: 0.9rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.dialog-actions button.primary { background: #378ADD; color: white; border-color: #378ADD; font-weight: 600; }
.dialog-actions button.danger { background: transparent; color: #c33; border-color: #c33; margin-left: auto; }

/* Recommendation results */
.rec-results { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; }
.rec-card {
  padding: 0.7rem 0.9rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.rec-card-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.rec-card-title { font-weight: 600; font-size: 1rem; }
.rec-card-author { color: var(--text-muted); font-size: 0.85rem; }
.rec-conf {
  padding: 0.1rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600;
  background: #378ADD; color: white; margin-left: auto;
}
.rec-conf.mid { background: #d8b02c; color: #3a2a08; }
.rec-conf.low { background: #b8ab8c; color: #3a2e18; }
.rec-engine {
  font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 4px;
  background: var(--card); color: var(--text-muted); border: 1px solid var(--border);
}
.rec-why { font-size: 0.88rem; margin-top: 0.35rem; line-height: 1.4; }
.rec-risk { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; font-style: italic; }
.rec-actions { display: flex; gap: 0.3rem; margin-top: 0.45rem; }
.rec-actions button {
  padding: 0.3rem 0.7rem; font-family: inherit; font-size: 0.8rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); cursor: pointer;
}
.rec-actions button.primary { background: #378ADD; color: white; border-color: #378ADD; }

/* ── Taste notes editor ─────────────────────────────── */
.notes-list { display: flex; flex-direction: column; gap: 1rem; }
.notes-group-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 0.6rem 0 0.3rem;
}
.note-card {
  padding: 0.7rem 0.9rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; margin-bottom: 0.4rem;
  transition: border-color 0.12s;
}
.note-card:hover { border-color: #378ADD; }
.note-card.inactive { opacity: 0.55; border-style: dashed; }
.note-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.note-title { font-weight: 600; font-size: 0.95rem; }
.note-content { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; margin-top: 0.3rem; white-space: pre-wrap; }

/* ── Recommendation history ─────────────────────────── */
.calibration {
  padding: 0.8rem 1rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 0.8rem;
}
.cal-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; }
.cal-bands { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.cal-band {
  padding: 0.5rem 0.4rem; text-align: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
}
.cal-band-name { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-band-rate { font-size: 1.2rem; font-weight: 700; margin: 0.15rem 0; }
.cal-band-count { font-size: 0.75rem; color: var(--text-muted); }
.cal-band.ok   { background: rgba(46, 168, 102, 0.14); border-color: #2ea866; }
.cal-band.high { background: rgba(216, 176, 44, 0.14); border-color: #d8b02c; }
.cal-band.low  { background: rgba(140, 58, 43, 0.14);  border-color: #8c3a2b; }
.cal-band.empty { opacity: 0.6; }

.recs-list { display: flex; flex-direction: column; gap: 0.6rem; }
.rec-outcome {
  margin-top: 0.5rem; padding: 0.5rem 0.7rem;
  background: rgba(46, 168, 102, 0.08); border: 1px solid #2ea866;
  border-radius: 6px; font-size: 0.85rem;
}
.rec-outcome-note { margin-top: 0.3rem; color: var(--text-muted); font-style: italic; }
.rec-generated { margin-top: 0.3rem; font-size: 0.75rem; }
