/* ─── Book-list container & cards ─── */
#bookList {
  display: grid;
  gap: 10px;
}
.book-item {
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.book-card {
  display: flex;
  gap: 12px;
  align-items: center;
  outline: none;
}
.book-card:focus {
  box-shadow: 0 0 0 3px rgba(0, 120, 255, 0.3);
  border-radius: 6px;
}
.book-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.book-title {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.book-actions button {
  cursor: pointer;
}

/* ─── Chapter list reset ─── */
.chapter-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ─── Chapter row: duration | title/button | edit + refresh bits ─── */
.chapter-list ul li {
  display: flex;
  align-items: center;
  /* no wrapping—everything stays on one line */
}
/* duration on left */
.chapter-list ul li .chap-dur {
  flex: none;
  margin-right: 0.5em;
  color: #678;
  font-variant-numeric: tabular-nums;
}

.chapter-list ul li .chap-dur {
  /* fix the column to exactly 6ch (e.g. "123:45" / "12:34:56" fits nicely) */
  width: 6ch;
  flex: none;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}

/* play button in center */
.chapter-list ul li > button {
  flex: 1 1 0;
  min-width: 0; /* allow shrinking & wrapping */
  max-width: 60ch; /* prevents ultra-wide buttons */
  display: inline-flex;
  align-items: center;
  justify-content: center; /* centers text */
  padding: 0.4em 0.6em;
  text-align: center;
}
/* edit link on right */
.chapter-list ul li .edit-link {
  flex: none;
  margin-left: 0.5em;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}
/* spinner / done / stats also on the right */
.chapter-list ul li .li-spinner,
.chapter-list ul li .li-done,
.chapter-list ul li .chap-stats {
  flex: none;
  margin-left: 0.5em;
  font-size: 0.9em;
}
/* push the spinner (and anything after it) to the far right */
.chapter-list ul li .li-spinner {
  margin-left: auto;
  animation: spin 1s linear infinite;
}
.chapter-list ul li .li-done {
  color: green;
}

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

/* ─── Cover-thumbnail styles ─── */
.cover-wrap {
  position: relative;
  width: 60px;
  height: 90px;
  border-radius: 4px;
  overflow: hidden;
  background: #f2f2f2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.view-grid .cover-wrap {
  width: 100%;
  height: auto;
  aspect-ratio: 2/3;
}
.cover-wrap .book-cover,
.cover-wrap .cover-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.book-cover {
  object-fit: cover;
  display: block;
}
.book-cover.no-cover {
  display: none;
}
.cover-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #678;
  background: #f6f6f6;
}
.book-cover.no-cover + .cover-fallback {
  display: flex;
}

/* ─── View modes ─── */
.view-list {
  grid-template-columns: 1fr;
}
.view-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.view-grid .book-item {
  padding: 0;
}
.view-grid .book-card {
  display: block;
  cursor: pointer;
}
.view-grid .book-meta {
  padding: 8px;
}
.view-grid .book-title {
  font-size: 1rem;
  line-height: 1.2;
}
.view-compact .book-item {
  padding: 6px;
}
.view-compact .cover-wrap {
  display: none;
}
.view-compact .book-actions {
  margin-top: 0;
}

/* ─── Responsive tweak ─── */
@media (max-width: 600px) {
  .view-grid .book-title {
    font-size: 0.9rem;
  }
}
