.library-page {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 16px 40px;
}

.library-head {
  margin-bottom: 18px;
}

.library-title {
  margin: 0 0 8px;
  font-size: 42px;
  line-height: 1.05;
  font-weight: 900;
}

.library-subtitle {
  margin: 0;
  opacity: .8;
  max-width: 760px;
  line-height: 1.55;
}

.library-toolbar {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  margin-bottom: 18px;
}

.library-search,
.library-select {
  width: 100%;
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 14px;
  background: #fff;
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
}

.library-search:focus,
.library-select:focus {
  border-color: #b9c7ff;
  box-shadow: 0 0 0 3px rgba(120, 140, 255, 0.10);
}

.library-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.library-count {
  opacity: .75;
  font-size: 14px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.library-card {
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 20px;
  background: #fff;
  overflow: hidden;
  display: grid;
  grid-template-columns: 150px 1fr;
  min-height: 210px;
  box-shadow: 0 10px 30px rgba(0,0,0,.04);
}

.library-card.no-cover {
  grid-template-columns: 1fr;
}

.library-cover {
  width: 150px;
  height: 210px;
  background: linear-gradient(180deg, #f7f8fc 0%, #eef2fb 100%);
  overflow: hidden;
}

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

.library-cover-fallback {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  opacity: .7;
  font-weight: 700;
}

.library-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.library-topline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.lib-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  background: #f3f5fb;
  color: #24324a;
  border: 1px solid #e1e7f5;
}

.lib-badge.free {
  background: #edf9f1;
  color: #21653a;
  border-color: #cfead9;
}

.lib-badge.paid {
  background: #fff4e8;
  color: #8a4a00;
  border-color: #ffdcb4;
}

.library-card-title {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 900;
  margin: 0;
}

.library-excerpt {
  margin: 0;
  color: #3a4252;
  line-height: 1.55;
  opacity: .92;
}

.library-price {
  font-weight: 700;
  font-size: 15px;
  color: #1f6feb;
}

.library-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-tag {
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f7f8fb;
  border: 1px solid #eceff5;
  color: #596275;
}

.library-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  flex-wrap: wrap;
}

.library-date {
  font-size: 13px;
  opacity: .65;
}

.library-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.library-empty {
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 18px;
  background: #fff;
  padding: 18px;
}

.library-empty-title {
  font-weight: 700;
}

.library-empty-text {
  opacity: .85;
  margin-top: 6px;
}

.library-bottom {
  margin-top: 20px;
  display: flex;
  justify-content: flex-start;
}

.library-modal-card {
  max-width: 980px;
  width: 94%;
}

.library-modal-title {
  text-transform: none;
}

.library-modal-meta {
  margin-top: 6px;
  text-transform: none;
}

.lib-modal-text {
  white-space: pre-wrap;
  text-transform: none;
  max-height: 60vh;
  overflow: auto;
  line-height: 1.65;
}

.library-modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 900px) {
  .library-toolbar {
    grid-template-columns: 1fr;
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .library-card {
    grid-template-columns: 1fr;
  }

  .library-cover {
    width: 100%;
    height: 240px;
  }

  .library-title {
    font-size: 32px;
  }
}

@media (max-width: 640px) {
  .library-page {
    margin: 16px auto;
    padding: 0 12px 28px;
  }

  .library-title {
    font-size: 28px;
  }

  .library-subtitle {
    font-size: 14px;
  }

  .library-search,
  .library-select {
    padding: 12px 14px;
    font-size: 14px;
  }

  .library-body {
    padding: 14px;
  }

  .library-card-title {
    font-size: 20px;
  }

  .library-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .library-actions {
    width: 100%;
  }

  .library-actions .pill-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .library-modal-card {
    width: 96%;
  }

  .lib-modal-text {
    max-height: 50vh;
    font-size: 14px;
  }
}