.subject-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.subject-filter-select {
  max-width: 320px;
  min-width: 250px;
  border: 1px solid #dbe7f5;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%238299B5' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  border-radius: 999px;
  padding: 10px 38px 10px 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #36557d;
  line-height: 1.3;
  box-shadow: 0 3px 10px rgba(50, 99, 161, 0.08);
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

.subject-filter-select:hover {
  border-color: #b7d1ef;
  box-shadow: 0 6px 16px rgba(50, 99, 161, 0.12);
}

.subject-filter-select:focus {
  outline: none;
  border-color: #84b8ee;
  box-shadow: 0 0 0 3px rgba(50, 159, 255, 0.2), 0 8px 18px rgba(50, 99, 161, 0.12);
}

.subject-filter-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid #dbe7f5;
  background: #fff;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  box-shadow: 0 3px 10px rgba(50, 99, 161, 0.08);
  transition: all 0.2s ease;
  gap: 8px;
}

.subject-filter-reset:hover {
  text-decoration: none;
  color: #27496d;
  border-color: #b7d1ef;
  box-shadow: 0 6px 16px rgba(50, 99, 161, 0.12);
}

.filter-empty-state {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #dbe7f5;
  border-radius: 20px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(50, 99, 161, 0.08);
}

.filter-empty-state svg {
  width: 120px;
  height: 120px;
  margin-bottom: 10px;
}

.empty-float {
  animation: emptyFloat 2.6s ease-in-out infinite;
  transform-origin: center;
}

.empty-blink {
  animation: emptyBlink 1.4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes emptyBlink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 0.9; }
}

/* --- Library card grid: 5 cols desktop, responsive below (overrides base .trending-grid) --- */
.trending-grid.lib-card-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.trending-grid.lib-card-grid-5 > .trending-card {
  min-width: 0;
}

@media (max-width: 1199px) {
  .trending-grid.lib-card-grid-5 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 991px) {
  .trending-grid.lib-card-grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 575px) {
  .trending-grid.lib-card-grid-5 {
    grid-template-columns: 1fr;
  }
}

/* --- Filter bar: stack full-width on narrow viewports --- */
#libraryFilterForm {
  max-width: 100%;
}

@media (max-width: 767px) {
  .subject-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .subject-filter-bar.form-inline .form-control.subject-filter-select {
    display: block;
    width: 100%;
    margin: 0;
    vertical-align: middle;
  }

  .subject-filter-select {
    min-width: 0;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
  }

  .subject-filter-reset {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
  }

  .filter-empty-state {
    padding: 20px 14px;
  }

  .filter-empty-state svg {
    width: 96px;
    height: 96px;
  }

  .library-content .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .library-content .section-header .lib-tab {
    align-self: stretch;
    text-align: center;
    justify-content: center;
  }
}
