/* =========================================================
   Unified Library (pages/portal/library.html)
   and the content admin's library page.
   Uses the tokens defined in styles.css (--navy, --teal...).
========================================================= */

.lib-page {
  background: var(--section-bg);
}

/* Elements of the library and basket pages that set their own display
   (flex, block...) must still disappear when the script hides them. */
.lib-page [hidden],
.lib-modal [hidden] {
  display: none !important;
}

/* ---------- Hero & search ---------- */

.lib-hero {
  position: relative;
  padding: 34px 0 30px;
  color: #ffffff;
  background:
    radial-gradient(circle at 12% 120%, rgba(0, 206, 183, 0.28) 0, transparent 42%),
    linear-gradient(135deg, #00344b 0%, #00495f 60%, #005865 100%);
  overflow: hidden;
}

.lib-hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -55% auto;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

.lib-breadcrumb {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.lib-breadcrumb a {
  color: rgba(255, 255, 255, 0.85);
}

.lib-hero h1 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.35;
  font-weight: 700;
}

.lib-hero p {
  margin: 0 0 20px;
  max-width: 640px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.lib-search {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 760px;
  height: 54px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(0, 20, 30, 0.22);
}

.lib-search svg {
  width: 22px;
  height: 22px;
  margin-right: 18px;
  flex: 0 0 auto;
  color: var(--teal-dark);
}

.lib-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}

.lib-search input::placeholder {
  color: #93a4ab;
}

.lib-search button {
  height: 42px;
  margin-left: 6px;
  padding: 0 22px;
  border: 0;
  border-radius: 7px;
  color: #ffffff;
  background: linear-gradient(135deg, #00a896 0%, #169c8c 100%);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.lib-popular {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
}

.lib-popular > span {
  color: rgba(255, 255, 255, 0.7);
}

.lib-popular button {
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lib-popular button:hover,
.lib-popular button.is-active {
  border-color: var(--teal);
  background: rgba(64, 188, 169, 0.28);
}

/* ---------- Layout ---------- */

.lib-body {
  padding: 26px 0 60px;
}

.lib-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

/* ---------- Sidebar ---------- */

.lib-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 14px);
  max-height: calc(100vh - var(--header-height) - 28px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.lib-filter + .lib-filter {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.lib-filter h2 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

.lib-segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border-radius: 8px;
  background: var(--section-bg);
}

.lib-segment button {
  padding: 7px 4px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.lib-segment button.is-active {
  color: var(--navy);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 52, 75, 0.12);
}

.lib-categories {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lib-cat-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  text-align: right;
  cursor: pointer;
}

.lib-cat-button:hover {
  background: var(--section-bg);
}

.lib-cat-button.is-active {
  color: #0d5c50;
  background: var(--teal-soft);
  font-weight: 700;
}

.lib-cat-button.is-empty {
  color: #a7b5ba;
}

.lib-cat-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 14px;
}

.lib-cat-name {
  flex: 1;
}

.lib-cat-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--section-bg);
  font-size: 11px;
  text-align: center;
}

.lib-subcategories {
  margin: 2px 0 6px;
  padding: 0 34px 0 0;
  list-style: none;
}

.lib-subcategories .lib-cat-button {
  padding: 6px 9px;
  font-size: 12.5px;
}

.lib-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lib-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.lib-chip.is-active {
  border-color: var(--teal-dark);
  color: #ffffff;
  background: var(--teal-dark);
}

.lib-clear {
  margin-top: 16px;
  padding: 0;
  border: 0;
  color: var(--teal-dark);
  background: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.lib-filter-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

/* ---------- Toolbar ---------- */

.lib-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.lib-result-count {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
  font-weight: 700;
}

.lib-result-count small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.lib-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.lib-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 11px;
  border-radius: 999px;
  color: var(--navy);
  background: var(--blue-soft);
  font-size: 12px;
}

.lib-pill button {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--navy);
  background: rgba(0, 52, 75, 0.08);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.lib-toolbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lib-select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: #ffffff;
  font-family: inherit;
  font-size: 13px;
}

.lib-filters-toggle {
  display: none;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--navy);
  background: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Cards ---------- */

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 18px;
}

.lib-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.lib-card:hover {
  border-color: #c9dde1;
  box-shadow: 0 12px 28px rgba(0, 52, 75, 0.1);
  transform: translateY(-2px);
}

.lib-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  background: linear-gradient(135deg, #eef4f5 0%, #f7fafb 100%);
  cursor: zoom-in;
}

.lib-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.lib-thumb-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #94a7ae;
  font-size: 12px;
}

.lib-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(0, 52, 75, 0.86);
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(2px);
}

.lib-badge.is-slide {
  background: rgba(22, 156, 140, 0.92);
}

.lib-thumb-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: rgba(0, 52, 75, 0.5);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lib-thumb:hover .lib-thumb-overlay,
.lib-thumb:focus-visible .lib-thumb-overlay {
  opacity: 1;
}

.lib-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 13px 14px 12px;
}

.lib-card-category {
  margin-bottom: 4px;
  color: var(--teal-dark);
  font-size: 11.5px;
  font-weight: 600;
}

.lib-card-title {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 700;
}

.lib-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.lib-tag {
  padding: 2px 8px;
  border: 0;
  border-radius: 5px;
  color: #506873;
  background: var(--section-bg);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.lib-tag:hover {
  color: var(--navy);
  background: var(--blue-soft);
}

.lib-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid #edf2f4;
  color: var(--muted);
  font-size: 11.5px;
}

.lib-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--teal-dark);
  border-radius: 6px;
  color: var(--navy);
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.lib-download svg {
  width: 15px;
  height: 15px;
}

.lib-download:hover {
  color: #ffffff;
  background: var(--teal-dark);
}

.lib-more {
  display: block;
  margin: 26px auto 0;
  padding: 11px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--navy);
  background: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.lib-empty {
  padding: 60px 20px;
  border: 1px dashed #cfdcdf;
  border-radius: 10px;
  color: var(--muted);
  background: #ffffff;
  text-align: center;
}

.lib-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
  font-size: 16px;
}

.lib-skeleton {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.lib-skeleton div {
  aspect-ratio: 16 / 9;
  background: linear-gradient(90deg, #eef3f5 0%, #f8fafb 50%, #eef3f5 100%);
  background-size: 200% 100%;
  animation: lib-shimmer 1.2s infinite linear;
}

.lib-skeleton p {
  height: 12px;
  margin: 14px;
  border-radius: 4px;
  background: #eef3f5;
}

@keyframes lib-shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Preview modal ---------- */

.lib-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lib-modal.is-open {
  display: flex;
}

.lib-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 25, 36, 0.72);
}

.lib-modal-dialog {
  position: relative;
  width: min(1180px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  overflow: hidden;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.lib-modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.92);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.lib-viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f1f5f6;
}

.lib-stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 22px;
  min-height: 0;
}

.lib-stage img {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 52, 75, 0.16);
  background: #ffffff;
}

.lib-stage-empty {
  color: var(--muted);
  font-size: 13px;
}

.lib-nav {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.92);
  font-size: 20px;
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.lib-nav[disabled] {
  opacity: 0.35;
  cursor: default;
}

.lib-nav.is-prev { right: 16px; }
.lib-nav.is-next { left: 16px; }

.lib-strip {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  overflow-x: auto;
}

.lib-strip button {
  flex: 0 0 auto;
  width: 108px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  background: #ffffff;
  cursor: pointer;
}

.lib-strip button.is-active {
  border-color: var(--teal);
}

.lib-strip img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.lib-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 22px 22px;
  overflow-y: auto;
}

.lib-info-kicker {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 600;
}

.lib-info h2 {
  margin: -8px 0 0;
  color: var(--navy);
  font-size: 19px;
  line-height: 1.5;
}

.lib-info p {
  margin: 0;
  color: #506873;
  font-size: 13px;
  line-height: 1.8;
}

.lib-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lib-fact {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--section-bg);
}

.lib-fact span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.lib-fact strong {
  color: var(--navy);
  font-size: 14px;
}

.lib-info-note {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.lib-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #005865 0%, #00434f 100%);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 52, 75, 0.16);
}

.lib-primary svg {
  width: 18px;
  height: 18px;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .lib-layout {
    grid-template-columns: 1fr;
  }

  .lib-sidebar {
    position: static;
    display: none;
    max-height: none;
  }

  .lib-sidebar.is-open {
    display: block;
  }

  .lib-filters-toggle {
    display: inline-block;
  }

  .lib-modal-dialog {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .lib-stage img {
    max-height: 52vh;
  }
}

@media (max-width: 640px) {
  .lib-hero h1 {
    font-size: 23px;
  }

  .lib-search {
    height: 50px;
  }

  .lib-search button {
    padding: 0 14px;
  }

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

  .lib-modal {
    padding: 0;
  }

  .lib-modal-dialog {
    max-height: 100vh;
    border-radius: 0;
  }
}

/* =========================================================
   Content admin: library page (content-admin/library-admin.html)
========================================================= */

.libadm-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.libadm-tab {
  position: relative;
  padding: 11px 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.libadm-tab.is-active {
  color: var(--navy);
}

.libadm-tab.is-active::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
}

.libadm-tab-count {
  margin-right: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  color: #ffffff;
  background: #d9822b;
  font-size: 11px;
}

.libadm-panel[hidden] {
  display: none;
}

.libadm-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.libadm-tools .content-admin-search {
  width: min(100%, 320px);
}

.libadm-tools .content-admin-search input {
  width: 100%;
  border: 0;
  outline: 0;
  font-family: inherit;
  font-size: 13px;
  background: transparent;
}

.libadm-select-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-inline-start: auto;
  color: var(--navy);
  font-size: 13px;
  cursor: pointer;
}

.libadm-bulk {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  z-index: 20;
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 10px 24px rgba(0, 52, 75, 0.22);
  font-size: 13px;
}

.libadm-bulk.is-visible {
  display: flex;
}

.libadm-bulk strong {
  margin-inline-end: 6px;
}

.libadm-bulk button,
.libadm-bulk select,
.libadm-bulk input {
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  font-family: inherit;
  font-size: 12.5px;
}

.libadm-bulk select option {
  color: var(--text);
}

.libadm-bulk input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.libadm-bulk button {
  cursor: pointer;
}

.libadm-bulk button.is-approve {
  border-color: var(--teal);
  background: var(--teal-dark);
}

.libadm-bulk button.is-danger {
  border-color: #e9a3a3;
  background: rgba(192, 57, 43, 0.35);
}

.libadm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.libadm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.libadm-card.is-selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(64, 188, 169, 0.3);
}

.libadm-check {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 20px;
  height: 20px;
  accent-color: var(--teal-dark);
  cursor: pointer;
}

.libadm-card .lib-thumb {
  cursor: zoom-in;
}

.libadm-status {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.libadm-status.is-draft {
  color: #7a4a00;
  background: #fff1d6;
}

.libadm-status.is-approved {
  color: #0d5c50;
  background: #dff5ef;
}

.libadm-fields {
  display: grid;
  gap: 9px;
  padding: 12px 13px 4px;
}

.libadm-fields label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.libadm-fields input,
.libadm-fields select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: #ffffff;
  font-family: inherit;
  font-size: 12.5px;
}

.libadm-fields input:focus,
.libadm-fields select:focus {
  border-color: var(--teal);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(64, 188, 169, 0.12);
}

.libadm-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 8px;
}

.libadm-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: auto;
  padding: 10px 13px 12px;
  color: var(--muted);
  font-size: 11px;
}

.libadm-saved {
  color: var(--teal-dark);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.libadm-saved.is-visible {
  opacity: 1;
}

.libadm-actions {
  display: flex;
  gap: 6px;
}

.libadm-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--navy);
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.libadm-btn.is-approve {
  border-color: var(--teal-dark);
  color: #ffffff;
  background: var(--teal-dark);
}

.libadm-btn.is-danger {
  color: #a3271b;
  border-color: #f0c9c5;
}

.libadm-btn:hover {
  filter: brightness(0.97);
}

.libadm-source {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

.libadm-empty {
  padding: 50px 20px;
  border: 1px dashed #cfdcdf;
  border-radius: 10px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.libadm-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
  font-size: 16px;
}

.libadm-empty .btn-builder-primary,
.libadm-empty .btn-builder-soft {
  margin: 14px 4px 0;
}

/* Decks table */

.libadm-deck-thumb {
  width: 112px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  background: var(--section-bg);
  border: 1px solid var(--border);
}

.libadm-table select,
.libadm-table input {
  width: 100%;
  min-width: 150px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  background: #ffffff;
}

/* Categories tree */

.libadm-cat-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.libadm-cat-add input {
  height: 40px;
  min-width: 260px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}

.libadm-tree {
  display: grid;
  gap: 10px;
}

.libadm-main {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.libadm-cat-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.libadm-main > .libadm-cat-row {
  background: #fbfcfd;
  border-bottom: 1px solid var(--border);
}

.libadm-children .libadm-cat-row {
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  padding-right: 40px;
}

.libadm-children .libadm-cat-row + .libadm-cat-row {
  border-top: 1px solid #f0f4f5;
}

.libadm-cat-row input[type="text"] {
  height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
}

.libadm-children .libadm-cat-row input[type="text"] {
  font-weight: 400;
}

.libadm-cat-row input[type="text"]:hover,
.libadm-cat-row input[type="text"]:focus {
  border-color: var(--border);
  background: #ffffff;
  outline: 0;
}

.libadm-cat-row input.libadm-icon {
  width: 46px;
  text-align: center;
  font-size: 16px;
}

.libadm-cat-row.is-hidden input[type="text"] {
  color: #a7b5ba;
  text-decoration: line-through;
}

.libadm-cat-meta {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.libadm-cat-buttons {
  display: flex;
  gap: 4px;
}

.libadm-cat-buttons button {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--navy);
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.libadm-cat-buttons button.is-danger {
  color: #a3271b;
}

.libadm-add-sub {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px 14px;
  padding-right: 40px;
  border-top: 1px solid #f0f4f5;
}

.libadm-add-sub input {
  flex: 1;
  max-width: 300px;
  height: 34px;
  padding: 0 10px;
  border: 1px dashed #cfdcdf;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
}

.libadm-progress {
  margin-top: 6px;
  height: 6px;
  border-radius: 6px;
  background: var(--section-bg);
  overflow: hidden;
}

.libadm-progress span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 6px;
  background: var(--teal);
  animation: libadm-progress 1.1s infinite ease-in-out;
}

@keyframes libadm-progress {
  0% { transform: translateX(160%); }
  100% { transform: translateX(-260%); }
}

@media (max-width: 760px) {
  .libadm-cat-row,
  .libadm-children .libadm-cat-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .libadm-cat-meta,
  .libadm-cat-buttons {
    grid-column: 2;
  }

  .libadm-tabs {
    overflow-x: auto;
  }
}

/* Presentation types (studio structures) */

.libadm-str-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.libadm-str-list {
  display: grid;
  gap: 14px;
}

.libadm-str {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.libadm-str.is-dirty {
  border-color: #00ceb7;
  box-shadow: 0 0 0 3px rgba(0, 206, 183, .12);
}

.libadm-str-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--border);
}

.libadm-str-titles {
  display: grid;
  gap: 2px;
}

.libadm-str input[type="text"] {
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--navy);
  font-family: inherit;
  font-size: 13px;
}

.libadm-str input[type="text"]:hover,
.libadm-str input[type="text"]:focus {
  border-color: var(--border);
  background: #ffffff;
  outline: 0;
}

.libadm-str input.libadm-icon {
  width: 46px;
  text-align: center;
  font-size: 18px;
}

.libadm-str input.libadm-str-name {
  font-size: 15px;
  font-weight: 700;
}

.libadm-str input.libadm-str-desc {
  height: 28px;
  color: var(--muted);
  font-size: 12px;
}

.libadm-str-state {
  color: #0a7d6f;
  font-size: 11.5px;
  white-space: nowrap;
}

.libadm-str.is-hidden .libadm-str-state {
  color: #a7b5ba;
}

.libadm-str.is-hidden .libadm-str-head input {
  color: #a7b5ba;
}

.libadm-str-sections {
  display: grid;
}

.libadm-str-section {
  display: grid;
  grid-template-columns: 28px minmax(140px, 220px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
}

.libadm-str-section + .libadm-str-section {
  border-top: 1px solid #f0f4f5;
}

.libadm-str-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #00344b;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.libadm-str input.libadm-str-sname {
  font-weight: 600;
}

.libadm-str-cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.libadm-str-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: #e6faf7;
  color: #00344b;
  font-size: 12px;
}

.libadm-str-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #5b7480;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.libadm-str-chip button:hover {
  background: #ffffff;
  color: #a3271b;
}

.libadm-str-empty {
  color: #a7b5ba;
  font-size: 12px;
}

.libadm-str-addcat {
  height: 28px;
  max-width: 170px;
  padding: 0 6px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
}

.libadm-str-section .libadm-cat-buttons button:disabled {
  opacity: .35;
  cursor: default;
}

.libadm-str-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
  border-top: 1px solid #f0f4f5;
}

.libadm-str-addsec {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.libadm-str-addsec input[type="text"] {
  width: 220px;
  border: 1px dashed var(--border);
  background: #ffffff;
}

.libadm-str-hint {
  display: none;
  color: #0a7d6f;
  font-size: 12px;
}

.libadm-str.is-dirty .libadm-str-hint {
  display: inline;
}

.libadm-str-save {
  opacity: .45;
  pointer-events: none;
}

.libadm-str.is-dirty .libadm-str-save {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 760px) {
  .libadm-str-head,
  .libadm-str-section {
    grid-template-columns: 1fr;
  }
  .libadm-str-addsec {
    margin-left: 0;
  }
}

/* Card buttons on one line («أضف إلى العرض» no longer wraps) */
.lib-card-footer { flex-wrap: wrap; row-gap: 8px; }
.lib-card-footer > span { white-space: nowrap; }
.lib-card-actions { flex: 1 1 auto; justify-content: flex-start; }
.lib-card-actions .lib-add,
.lib-card-actions .lib-download { white-space: nowrap; }

/* Design versions (1..7 items) under the large preview */
.lib-strip .lib-variant { width: 128px; display: grid; gap: 0; background: #ffffff; }
.lib-variant-label { display: block; padding: 5px 4px 6px; color: #00344b; font-size: 12px; font-weight: 600; text-align: center; }
.lib-strip .lib-variant.is-active .lib-variant-label { background: #00344b; color: #ffffff; }
.lib-variant-empty { display: block; aspect-ratio: 16 / 9; background: #eef3f4; }

/* «مشاركاتي» link under the search */
.lib-share-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 7px 14px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 999px; background: rgba(255, 255, 255, .08); color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; transition: background .15s ease, border-color .15s ease; }
.lib-share-link svg { width: 18px; height: 18px; color: #00ceb7; }
.lib-share-link:hover { background: rgba(255, 255, 255, .16); border-color: #00ceb7; }
