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

/* =========================================================
   Head / hero
   ========================================================= */

.library-head {
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  padding: 26px 28px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, #0f172a, #1e293b);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.12);
}

.library-head::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(
      135deg,
      transparent 77%,
      rgba(34, 197, 94, 0.7) 77%,
      rgba(34, 197, 94, 0.7) 78%,
      transparent 78%,
      transparent 79.5%,
      #22c55e 79.5%,
      #22c55e 81.2%,
      transparent 81.2%
    );
}

.library-head::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(
      135deg,
      transparent 79%,
      rgba(34, 197, 94, 0.16) 80%,
      transparent 81%
    );
  filter: blur(6px);
  opacity: 0.55;
}

.library-head > * {
  position: relative;
  z-index: 1;
}

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

.library-subtitle {
  margin: 0;
  max-width: 760px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.78);
}

.library-subtitle + .library-subtitle {
  margin-top: 6px;
}

/* =========================================================
   Links / nav
   ========================================================= */

.back-home-link {
  display: inline-block;
  margin: 2px 0 18px;
  color: #111827;
  text-decoration: none;
  font-weight: 700;
}

.back-home-link:hover {
  text-decoration: underline;
}
.result-block h3::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  margin-right: 8px;
}

/* =========================================================
   Grid
   ========================================================= */

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

.library-card {
  border: 1px solid var(--border, #dbe4dc);
  border-radius: 20px;
  background: #fff;
  overflow: hidden;
  min-height: 210px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-decoration: none !important;
  color: inherit !important;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(17, 24, 39, 0.08);
  border-color: rgba(22, 163, 74, 0.18);
  text-decoration: none !important;
  color: inherit !important;
}

.library-card:link,
.library-card:visited,
.library-card:active,
.library-card:focus {
  text-decoration: none !important;
  color: inherit !important;
}

.library-card * {
  text-decoration: none !important;
}

.library-card.no-cover {
  display: block;
}

.library-body {
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  height: 100%;
}

.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 !important;
  border: 1px solid #e1e7f5;
}

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

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

.library-card-title {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 900;
  margin: 0;
  color: #111827 !important;
  overflow-wrap: break-word;
}

.library-excerpt {
  margin: 0;
  color: #3a4252 !important;
  line-height: 1.6;
  opacity: 0.95;
}

/* =========================================================
   Bottom
   ========================================================= */

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

/* =========================================================
   Optional shared library blocks
   ========================================================= */

.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, #dbe4dc);
  border-radius: 14px;
  background: #fff;
  padding: 14px 16px;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  color: var(--text, #111827);
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.04);
}

.library-search::placeholder {
  color: rgba(17, 24, 39, 0.45);
}

.library-search:focus,
.library-select:focus {
  border-color: rgba(22, 163, 74, 0.42);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

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

.library-count {
  opacity: 0.75;
  font-size: 14px;
  color: var(--muted, rgba(17, 24, 39, 0.65));
}

.library-cover {
  width: 150px;
  min-width: 150px;
  min-height: 210px;
  background: linear-gradient(180deg, #f7fbf8 0%, #edf5ef 100%);
  overflow: visible;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.library-cover img {
  width: 100%;
  height: auto;
  max-height: 210px;
  object-fit: contain;
  object-position: top center;
  display: block;
  border-radius: 14px;
}

.library-cover-fallback {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0.7;
  font-weight: 700;
  color: var(--text, #111827);
}

.library-price {
  font-weight: 800;
  font-size: 15px;
  color: #15803d;
}

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

.library-tag {
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #f7faf7;
  border: 1px solid #e7efe8;
  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: 0.65;
}

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

.library-empty {
  border: 1px solid var(--border, #dbe4dc);
  border-radius: 18px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.04);
}

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

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

.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;
}

/* =========================================================
   Responsive
   ========================================================= */

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

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

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

  .library-head::after {
    background:
      linear-gradient(
        135deg,
        transparent 72%,
        rgba(34, 197, 94, 0.7) 72%,
        rgba(34, 197, 94, 0.7) 73.2%,
        transparent 73.2%,
        transparent 75.2%,
        #22c55e 75.2%,
        #22c55e 76.8%,
        transparent 76.8%
      );
  }
}

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

  .library-head {
    padding: 20px 20px;
    border-radius: 18px;
  }

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

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

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

  .library-body {
    padding: 16px;
  }

  .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;
  }

  .library-head::after {
    background:
      linear-gradient(
        135deg,
        transparent 68%,
        rgba(34, 197, 94, 0.7) 68%,
        rgba(34, 197, 94, 0.7) 69.2%,
        transparent 69.2%,
        transparent 71.2%,
        #22c55e 71.2%,
        #22c55e 72.8%,
        transparent 72.8%
      );
  }
}

/* =========================================================
   Short test
   ========================================================= */

.test-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.test-card {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.035);
  padding: 18px 18px 20px;
}

.test-progress {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(15, 23, 42, 0.5);
  font-weight: 700;
}

.test-question {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.22;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.78);
  max-width: 640px;
}

.test-answers {
  display: grid;
  gap: 12px;
}

.answer-btn {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0 18px;
  min-height: 60px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
  box-shadow: 0 4px 14px rgba(17, 24, 39, 0.02);
  display: block;
}

.answer-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 197, 94, 0.22);
  background: rgba(255, 255, 255, 0.86);
}

.answer-inner {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  column-gap: 14px;
  min-height: 60px;
  width: 100%;
}

.answer-label {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: #243042;
  color: #fff;
  margin: 0;
}

.answer-text {
  display: block;
  font-size: 15px;
  line-height: 1.45;
  color: rgba(15, 23, 42, 0.56);
  font-weight: 500;
  margin: 0;
}
.answer-btn,
.answer-btn * {
  box-sizing: border-box;
}

.answer-btn .answer-label {
  justify-self: center;
}

.answer-btn .answer-text {
  align-self: center;
}
.answer-btn .answer-label,
.answer-btn .answer-text {
  vertical-align: middle;
}

.answer-btn:hover .answer-label {
  background: #1f7a34;
}

.test-section-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #edf9f1;
  color: #21653a;
  border: 1px solid #cfead9;
}

.result-block {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.035);
  margin-bottom: 14px;
}

.result-block h3 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
  color: rgba(15, 23, 42, 0.88);
}

.result-block p {
  margin: 0;
  line-height: 1.7;
  color: rgba(15, 23, 42, 0.66);
  white-space: pre-line;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.result-mini {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.66);
}

.result-mini-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 900;
  color: rgba(15, 23, 42, 0.86);
}

.result-mini-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: rgba(15, 23, 42, 0.64);
  white-space: pre-line;
}

.score-line {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.44);
}

.result-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  border: 1px solid #0f172a;
}

.cta-btn.secondary {
  background: rgba(255, 255, 255, 0.82);
  color: rgba(15, 23, 42, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

@media (max-width: 700px) {
  .test-question {
    font-size: 21px;
    line-height: 1.24;
  }

  .answer-text {
    font-size: 14px;
  }

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

  .test-card {
    padding: 16px;
  }

  .answer-btn {
    padding: 13px 14px;
  }
}