.books-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.books-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.books-intro h2 {
  font-size: 1.5rem;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.books-intro-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.books-intro p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.checklist-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.checklist-form .form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background-color: white;
}

.checklist-form .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  outline: none;
}

.checklist-form .icon-btn {
  width: 44px;
  height: 44px;
}

.books-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(99, 102, 241, 0.08);
  padding: 0.35rem;
  border-radius: 999px;
  width: fit-content;
}

.books-tab {
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.books-tab.active {
  background: white;
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.books-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.5rem;
}

.books-layout.no-selection {
  grid-template-columns: 1fr;
}

.checklists-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checklist-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.checklist-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.checklist-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.checklist-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.checklist-item-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
}

.checklist-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

.checklist-detail {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
}

.checklist-detail.hidden {
  display: none;
}

.checklist-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checklist-detail-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.checklist-detail-title h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--dark);
}

.period-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-dark);
}

.icon-btn {
  border: none;
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary-dark);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.icon-btn.tiny {
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
}

.icon-btn.primary {
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-dark);
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(99, 102, 241, 0.2);
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.book-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary);
}

.book-row.completed {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.08);
}

.book-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.book-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.book-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.book-title-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.book-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.book-title-text {
  font-weight: 600;
  color: var(--dark);
}

.book-pages-inline {
  font-weight: 600;
  color: var(--text-light);
}

.book-title-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.book-title-input[readonly] {
  background: rgba(99, 102, 241, 0.05);
  cursor: default;
}

.book-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.book-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.book-progress .progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(99, 102, 241, 0.12);
  position: relative;
}

.book-progress .progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary-dark), var(--primary-light));
}

.progress-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  background: rgba(99, 102, 241, 0.8);
  border-radius: 2px;
  transform: translateX(-1px);
}

.book-pace {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
  flex-wrap: wrap;
}

.pace-status {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pace-status.on-track {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.pace-status.behind {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.pace-status.ahead {
  background: rgba(37, 99, 235, 0.15);
  color: #2563eb;
}

.pace-status.waiting {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-light);
}

.book-status {
  font-weight: 600;
  color: var(--success);
}

.book-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.book-controls input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.book-inputs {
  display: grid;
  grid-template-columns: minmax(110px, 1fr);
  gap: 0.5rem;
  flex: 1;
}

.book-controls.editing .book-inputs {
  grid-template-columns: repeat(2, minmax(110px, 1fr));
}

.book-input-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.book-input-field label {
  font-size: 0.75rem;
  color: var(--text-light);
}

.book-actions {
  display: flex;
  gap: 0.5rem;
}

.book-actions .icon-btn {
  width: 36px;
  height: 36px;
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.book-form {
  display: grid;
  grid-template-columns: 1fr 120px 44px;
  gap: 0.5rem;
}

.book-form input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.books-section-title {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.empty-state {
  color: var(--text-light);
  text-align: center;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.hidden {
  display: none !important;
}

/* Dark mode */
.dark-mode .books-header,
.dark-mode .checklist-detail,
.dark-mode .checklist-item {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.dark-mode .books-intro h2 {
  color: #e2e8f0;
}

.dark-mode .checklist-item-title,
.dark-mode .checklist-detail-title h3 {
  color: #e2e8f0;
}

.dark-mode .book-title-text {
  color: #e2e8f0;
}

.dark-mode .book-pages-inline {
  color: #cbd5f5;
}

.dark-mode .progress-marker {
  background: rgba(129, 140, 248, 0.9);
}

.dark-mode .pace-status.on-track {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.dark-mode .pace-status.behind {
  background: rgba(248, 113, 113, 0.2);
  color: #fecaca;
}

.dark-mode .pace-status.ahead {
  background: rgba(96, 165, 250, 0.2);
  color: #bfdbfe;
}

.dark-mode .pace-status.waiting {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5f5;
}

.dark-mode .checklist-item.active {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.2);
}

.dark-mode .book-row {
  background: #0f172a;
  border-color: #334155;
}

.dark-mode .book-row.completed {
  background: rgba(16, 185, 129, 0.12);
}

.dark-mode .book-title-input,
.dark-mode .book-controls input,
.dark-mode .book-form input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

.dark-mode .book-number {
  background: rgba(129, 140, 248, 0.2);
  color: #c7d2fe;
}

.dark-mode .book-title-input[readonly] {
  background: rgba(15, 23, 42, 0.6);
}

.dark-mode .checklist-form .form-control {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

.dark-mode .period-badge {
  background: rgba(129, 140, 248, 0.2);
  color: #c7d2fe;
}

.dark-mode .icon-btn {
  background: rgba(129, 140, 248, 0.15);
  color: #c7d2fe;
}

.dark-mode .icon-btn.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.dark-mode .books-section-title {
  border-top-color: #334155;
  color: #94a3b8;
}

.dark-mode .books-tab.active {
  background: #1e293b;
  color: #c7d2fe;
}

.dark-mode .books-tabs {
  background: rgba(129, 140, 248, 0.15);
}

/* Responsive */
@media (max-width: 900px) {
  .checklist-form {
    grid-template-columns: 1fr;
  }

  .books-layout {
    grid-template-columns: 1fr;
  }

  .books-layout.detail-open .checklists-panel {
    display: none;
  }

  .books-layout.detail-open .checklist-detail {
    display: flex;
  }

  .book-form {
    grid-template-columns: 1fr 1fr 44px;
  }

  .book-inputs {
    grid-template-columns: minmax(120px, 1fr);
  }

  .book-controls.editing .book-inputs {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 600px) {
  .book-controls {
    flex-direction: column;
  }

  .book-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .book-inputs {
    grid-template-columns: 1fr;
  }

  .book-form {
    grid-template-columns: 1fr;
  }
}
