/* ---- Library overlays: Resources + Knowledge Academy ---- */
.lib-panel { max-width: 1120px; }

/* toolbar: search + view switch */
.lib-bar { display: flex; gap: 10px; align-items: center; position: sticky; top: -1px; z-index: 2;
  background: var(--surface); padding: 2px 0 10px; }
.lib-bar[hidden] { display: none; }
.lib-search { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; margin: 0; }
.lib-search > svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.lib-search input {
  width: 100%; box-sizing: border-box; height: 46px; padding: 0 74px 0 42px; font: inherit; font-size: 15px;
  color: var(--slate); background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s; -webkit-appearance: none; appearance: none;
}
.lib-search input::-webkit-search-cancel-button { display: none; }
.lib-search input::placeholder { color: var(--muted); }
.lib-search input:focus { outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.lib-clear { position: absolute; right: 40px; width: 28px; height: 28px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-size: 18px; line-height: 1; }
.lib-clear:hover { background: var(--primary); color: #fff; }
.lib-clear[hidden] { display: none; }
.lib-kbd { position: absolute; right: 12px; min-width: 20px; height: 22px; display: grid; place-items: center;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; font: 600 12px/1 ui-monospace, monospace;
  color: var(--muted); background: var(--surface); pointer-events: none; }
.lib-search input:focus ~ .lib-kbd { opacity: 0; }

.lib-view { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); flex: none; }
.lib-view button { width: 40px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.lib-view button svg { width: 19px; height: 19px; }
.lib-view button:hover { color: var(--primary); }
.lib-view button.on { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* filter chips + result line */
.lib-chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.lib-chips::-webkit-scrollbar { display: none; }
.lib-chips[hidden] { display: none; }
.lib-chip { flex: none; font: 600 13px/1 inherit; font-family: inherit; padding: 8px 13px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--slate-soft); transition: all .14s; }
.lib-chip:hover { border-color: var(--primary); color: var(--primary); }
.lib-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.lib-meta { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 2px 2px 12px; }
.lib-meta[hidden], .lib-body[hidden] { display: none !important; }
.lib-reset { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }
.lib-empty { color: var(--muted); padding: 40px 10px; text-align: center; line-height: 1.8; grid-column: 1 / -1; }
.lib mark { background: color-mix(in srgb, var(--accent) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* shared bits */
.lib-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.lib-tag { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--slate-soft); }
.lib-lock { font-size: 11.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.lib-count { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.lib-badge, .lib-thumb--badge { display: grid; place-items: center; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent); }
.lib-badge { width: 38px; height: 38px; border-radius: 10px; }
.lib-badge svg { width: 22px; height: 22px; }

/* ---- grid view ---- */
.lib-body.is-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.lib-card { all: unset; box-sizing: border-box; display: flex; flex-direction: column; cursor: pointer; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; color: var(--slate);
  transition: transform .16s, box-shadow .16s, border-color .16s; }
.lib-card:hover, .lib-card:focus-visible { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); }
.lib-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.lib-cover { display: block; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.lib-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.lib-card:hover .lib-cover img { transform: scale(1.04); }
.lib-cover--icon { display: grid; place-items: center; font-size: 42px;
  background: linear-gradient(135deg, var(--surface-2), color-mix(in srgb, var(--primary) 14%, var(--surface-2))); }
.lib-card__body { display: flex; flex-direction: column; gap: 8px; padding: 16px 16px 14px; flex: 1; }
.lib-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lib-card__k { font-size: 11.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--primary); }
.lib-card__t { font-size: 17px; font-weight: 800; line-height: 1.25; letter-spacing: -.2px; }
.lib-card__d { font-size: 13.5px; line-height: 1.55; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.lib-card__d.lib-clamp3 { -webkit-line-clamp: 3; }
.lib-card__foot { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 4px; }
.lib-card__cta { margin-top: auto; padding-top: 6px; font-size: 13.5px; font-weight: 700; color: var(--primary); }
.lib-card--acad { border-top: 4px solid var(--primary); }
.lib-card--acad.is-locked { border-top-color: var(--accent); }
.lib-card--acad.is-locked .lib-badge { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---- list view ---- */
.lib-body.is-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.lib-body.is-list .lib-empty { border: 0; }
.lib-row { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 14px; padding: 12px 14px; cursor: pointer;
  background: var(--surface); color: var(--slate); border-top: 1px solid var(--border); transition: background .12s; min-width: 0; }
.lib-row:first-child { border-top: 0; }
.lib-row:hover, .lib-row:focus-visible { background: var(--surface-2); }
.lib-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.lib-thumb { flex: none; width: 64px; height: 48px; border-radius: 9px; overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; font-size: 22px; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-thumb--badge { width: 48px; height: 48px; border-radius: 12px; }
.lib-thumb--badge svg { width: 26px; height: 26px; }
.lib-row.is-locked .lib-thumb--badge { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lib-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lib-row__t { font-size: 15.5px; font-weight: 800; line-height: 1.3; }
.lib-row__t .lib-lock { margin-left: 8px; vertical-align: 1px; }
.lib-row__k { font-size: 11.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--primary); }
.lib-row__d { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-row__counts { display: flex; gap: 12px; flex-wrap: wrap; }
.lib-row .lib-tags { margin-top: 2px; }
.lib-row__go { flex: none; font-size: 26px; line-height: 1; color: var(--muted); transition: transform .15s, color .15s; }
.lib-row:hover .lib-row__go { color: var(--primary); transform: translateX(3px); }

/* ---- detail page (resources) ---- */
.lib-detail[hidden] { display: none; }
.lib-back { border: 1px solid var(--border); background: var(--surface); color: var(--primary); font: 700 13.5px/1 inherit;
  font-family: inherit; padding: 9px 14px; border-radius: 10px; cursor: pointer; margin-bottom: 14px; }
.lib-back:hover { border-color: var(--primary); }
.lib-detail__t { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 0 0 10px; color: var(--slate); }
.lib-detail__d { font-size: 14.5px; line-height: 1.65; color: var(--slate); margin-bottom: 16px; max-width: 75ch; }
.lib-files { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.lib-file { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--slate);
  background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; transition: border-color .15s; }
.lib-file:hover { border-color: var(--primary); }
.lib-file__ic { font-size: 20px; }
.lib-file__n { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.lib-file__n small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.lib-file__go { font-weight: 700; font-size: 13px; color: var(--primary); }
.lib-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 14px; }
.lib-gallery figure { margin: 0; }
.lib-gallery img { width: 100%; height: auto; display: block; border-radius: 11px; border: 1px solid var(--border); cursor: zoom-in; background: #fff; }
.lib-gallery figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

@media (max-width: 640px) {
  .lib-bar { gap: 8px; }
  .lib-search input { height: 44px; font-size: 16px; padding-right: 44px; }  /* 16px stops iOS zoom */
  .lib-kbd { display: none; }
  .lib-clear { right: 8px; }
  .lib-view button { width: 36px; height: 36px; }
  .lib-row { gap: 12px; padding: 11px 12px; }
  .lib-thumb { width: 52px; height: 42px; }
  .lib-thumb--badge { width: 42px; height: 42px; }
  .lib-row__d { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

/* phone fixes: the footer link row and the header buttons used to push the page
   wider than the screen (sideways scrolling) — let them wrap/shrink instead */
.sitefoot__links { flex-wrap: wrap; justify-content: center; row-gap: 6px; }
@media (max-width: 480px) {
  .topbar__right { gap: 8px; min-width: 0; }
  .topbar__meta { display: none; }
}
