/* ===========================
   Reset & Base
=========================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background-color: #fafaf9;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ===========================
   Layout
=========================== */
.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ===========================
   Header
=========================== */
header {
  margin-bottom: 32px;
}

header h1 {
  font-family: 'Lora', serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  color: #1a1a1a;
}

header p {
  font-size: 14px;
  color: #888;
}

/* ===========================
   Search Bar
=========================== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  height: 40px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: #aaa;
}

.search-bar button {
  height: 40px;
  padding: 0 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.search-bar button:hover {
  opacity: 0.75;
}

.search-bar button:active {
  opacity: 0.55;
}

/* ===========================
   Tabs
=========================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 20px;
}

.tab {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 400;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: #1a1a1a;
}

.tab.active {
  color: #1a1a1a;
  font-weight: 500;
  border-bottom: 2px solid #1a1a1a;
}

/* ===========================
   Genre Pills
=========================== */
.genre-pills {
  display: none; /* shown via JS when genre tab is active */
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.pill {
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid #ddd;
  background: #f4f4f4;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pill:hover {
  background: #e8e8e8;
  color: #1a1a1a;
}

.pill.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

/* ===========================
   Status Text
=========================== */
.status {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
  min-height: 20px;
}

/* ===========================
   Book Grid
=========================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}

/* ===========================
   Book Card
=========================== */
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cover-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e5e5;
  background: #f0ede8;
}

.cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Shown when there is no cover image */
.cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 11px;
  color: #aaa;
  text-align: center;
  padding: 12px;
  line-height: 1.4;
}

.card-title {
  font-family: 'Lora', serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: #1a1a1a;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: 11px;
  color: #888;
  line-height: 1.3;
  /* Clamp to 1 line */
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-year {
  font-size: 11px;
  color: #bbb;
}

/* ===========================
   Empty State
=========================== */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  font-size: 14px;
  color: #aaa;
}

/* ===========================
   Skeleton Loading
=========================== */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.skeleton .cover-wrap {
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton .card-title,
.skeleton .card-author {
  height: 12px;
  border-radius: 4px;
  background: #e5e5e5;
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton .card-author {
  width: 60%;
  height: 10px;
}
/* ===========================
   Add-to-list menu on cards
=========================== */
.list-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.list-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.list-btn:hover {
  background: #f4f4f4;
  color: #1a1a1a;
  border-color: #bbb;
}

/* ===========================
   My Lists view
=========================== */
.list-heading {
  grid-column: 1 / -1;
  font-family: 'Lora', serif;
  font-size: 20px;
  font-weight: 500;
  color: #1a1a1a;
  margin: 24px 0 4px;
}

.list-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}

/* ===========================
   Add-to-list menu on cards
=========================== */
.list-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.list-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.list-btn:hover {
  background: #f4f4f4;
  color: #1a1a1a;
  border-color: #bbb;
}

/* ===========================
   "Add to list" popup (YouTube-style)
=========================== */
.add-popup {
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 8px;
  min-width: 180px;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  cursor: pointer;
}

.add-create {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  border: none;
  border-top: 1px solid #eee;
  background: none;
  color: #1a1a1a;
  cursor: pointer;
  text-align: left;
}

.add-create:hover {
  color: #666;
}

/* ===========================
   My Lists view (sidebar + content)
=========================== */
.lists-layout {
  grid-column: 1 / -1;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.lists-sidebar {
  flex-shrink: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-nav {
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
}

.list-nav:hover {
  background: #f4f4f4;
}

.list-nav.active {
  background: #1a1a1a;
  color: #fff;
}

.list-new {
  text-align: left;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  padding: 8px 10px;
  margin-top: 8px;
  border: 1px dashed #ccc;
  border-radius: 6px;
  background: none;
  color: #888;
  cursor: pointer;
}

.list-new:hover {
  color: #1a1a1a;
  border-color: #999;
}

.lists-content {
  flex: 1;
}

.list-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.list-action {
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #666;
  cursor: pointer;
}

.list-action:hover {
  background: #f4f4f4;
  color: #1a1a1a;
}

.list-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}

/* Recommendation sections */
.rec-heading {
  grid-column: 1 / -1;
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 500;
  color: #1a1a1a;
  margin: 24px 0 4px;
}

.rec-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}