/* Homepage layout only. Workspace, analytics, administration and player styles stay separate. */
body.home-layout-active {
  --home-gutter: clamp(16px, 2.5vw, 96px);
  --home-tool-width: clamp(152px, 6vw, 208px);
  --home-tool-gap: 24px;
  --home-start: calc(var(--home-gutter) + var(--home-tool-width) + var(--home-tool-gap));
  --home-text-size: clamp(14px, .6vw, 20px);
}
#libraryView { width: calc(100% - 32px); margin: 0 16px; }
#libraryView .library-hero {
  width: 100%; max-width: none; min-height: 140px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px; margin: 14px 0; padding: 16px 22px;
  border: 1px solid #e2e9f8; border-radius: 18px;
  background: linear-gradient(110deg, #edf3ff, #f9fbff 70%);
  overflow: visible;
}
#libraryView .library-hero::before { display: none; }
#libraryView .hero-copy { max-width: none; min-width: 0; }
#libraryView .hero-copy > *, #libraryView .course-showcase { animation: none; }
#libraryView .hero-copy h1 { margin: 0; font-size: clamp(23px, 2.1vw, 30px); line-height: 1.3; letter-spacing: -.035em; }
#libraryView .hero-copy .hero-lead { margin: 6px 0 0; font-size: 13px; line-height: 1.6; }
#libraryView .hero-copy .hero-actions { gap: 20px; margin: 8px 0 0; }
#libraryView .hero-total { color: #6b7892; font-size: 12px; }
#libraryView .hero-total b { color: var(--blue); font-size: 16px; }
#libraryView .hero-text-button { min-height: 30px; padding: 3px 0; color: #506688; font-size: 12px; }
#libraryView .course-showcase {
  display: grid; grid-template-columns: 144px minmax(0, 1fr);
  grid-template-rows: auto auto 15px; column-gap: 16px; row-gap: 3px;
  width: 100%; max-width: none; min-width: 0; margin: 0; padding: 0;
}
#libraryView .showcase-head { grid-column: 2; grid-row: 1; display: block; margin: 0; padding: 0; line-height: 1.2; }
#libraryView .showcase-head strong { color: var(--blue); font-size: 11px; letter-spacing: .05em; }
#libraryView .showcase-cover { grid-column: 1; grid-row: 1 / 4; align-self: center; width: 144px; margin: 0; padding: 0; border-radius: 12px; box-shadow: 0 4px 14px #315edb10; }
#libraryView .showcase-cover-inner { border-radius: 12px; transform: none; }
#libraryView .showcase-cover:hover .showcase-cover-inner { transform: none; }
#libraryView .showcase-hover-action { display: none; }
#libraryView .showcase-loading { font-size: 11px; }
#libraryView .showcase-info { grid-column: 2; grid-row: 2; display: block; width: 100%; min-width: 0; min-height: 0; margin: 0; padding: 0; transform: none; }
#libraryView .showcase-course-copy { gap: 1px; }
#libraryView .showcase-course-copy > span { font-size: 10px; line-height: 1.3; }
#libraryView .showcase-course-copy > strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 14px; line-height: 1.4; }
#libraryView .showcase-duration { display: flex; gap: 2px; align-items: center; margin: 3px 0 0; padding: 0; border: 0; color: #7b869c; }
#libraryView .showcase-duration strong, #libraryView .showcase-explore { font-size: 10px; font-weight: 500; line-height: 1.4; }
#libraryView .showcase-explore { display: inline; color: #7b869c; }
#libraryView .showcase-pagination { grid-column: 2; grid-row: 3; justify-content: flex-start; gap: 3px; min-width: 0; margin: 0; overflow-x: auto; scrollbar-width: none; }
#libraryView .showcase-pagination::-webkit-scrollbar { display: none; }
#libraryView .showcase-pagination button { flex: 0 0 5px; width: 5px; height: 5px; }
#libraryView .showcase-pagination button.is-active { flex-basis: 12px; width: 12px; }

#libraryView .search-panel { max-width: none; width: 100%; padding: 0 0 12px; }
#libraryView .search-input-area { position: relative; z-index: 5; }
#libraryView .searchbox { min-height: 46px; border-radius: 12px; box-shadow: 0 4px 18px #315edb06; }
#libraryView .searchbox input { font-size: 14px; }
#libraryView .searchbox kbd { font-size: 11px; }
#libraryView .hot-searches { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); gap: 6px; margin: 0; padding: 12px 16px; border: 1px solid #dfe6f4; border-radius: 12px; background: #fff; box-shadow: 0 12px 24px #243d7c14; }
#libraryView .search-input-area:focus-within .hot-searches { display: flex; flex-wrap: wrap; }
#libraryView .hot-searches button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
#libraryView .filter-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; margin-top: 7px; }
#libraryView .filter-row > b { flex: 0 0 38px; width: 38px; color: #7a859b; font-size: 12px; }
#libraryView .quick-filters { display: flex; flex-wrap: wrap; gap: 6px; width: auto; min-width: 0; padding: 0; }
#libraryView .filter-chip { min-height: 30px; padding: 4px 11px; font-size: 12px; }
#libraryView .filter-options { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
#libraryView .topic-filter { flex: none; min-height: 30px; margin-left: 5px; padding: 4px 10px; border: 1px dashed #c8d4ec; border-radius: 999px; background: #fff; color: #6c7c9c; font-size: 11px; cursor: pointer; }
#libraryView .topic-filter:hover { color: var(--blue); border-color: var(--blue); }

#libraryView .gallery-section { max-width: none; width: 100%; margin: 0; padding: 10px 0 28px; background: transparent; border-top: 1px solid #e5ebf6; }
#libraryView .resource-heading { flex-direction: row; align-items: center; gap: 12px; margin: 0 0 10px; }
#libraryView .resource-heading > div { display: flex; align-items: baseline; gap: 12px; }
#libraryView .resource-heading .gallery-controls { align-items: center; gap: 14px; }
#libraryView .resource-heading h2 { margin: 0; font-size: 23px; line-height: 1.4; }
#libraryView #searchResultStatus { color: #8290a6; font-size: 12px; }
#libraryView .reset-filters { display: inline-flex; align-items: center; gap: 6px; padding: 5px 0; border: 0; background: none; color: #7082a4; cursor: pointer; font-size: 11px; white-space: nowrap; }
#libraryView .reset-filters:hover { color: var(--blue); }
#libraryView .learning-route { display: flex; gap: 6px; margin: 0 0 12px; padding: 0; overflow-x: auto; scrollbar-width: none; }
#libraryView .learning-route button { display: flex; flex: none; align-items: center; gap: 6px; min-height: 34px; padding: 5px 12px; border-radius: 9px; background: #f5f7fb; box-shadow: none; }
#libraryView .learning-route button.is-active { background: #eaf0ff; border-color: #c3d2fc; color: #315edb; }
#libraryView .learning-route button:hover { transform: none; border-color: #b2c5f0; }
#libraryView .learning-route small { color: #9aa8c0; font-size: 10px; letter-spacing: 0; }
#libraryView .learning-route strong { font-size: 12px; font-weight: 650; }
#libraryView .sort-switch { flex: none; width: auto; padding: 2px; border-radius: 8px; }
#libraryView .sort-switch button { min-height: 26px; padding: 4px 10px; border-radius: 6px; font-size: 11px; }
#libraryView .resource-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; scroll-margin-top: 90px; }
#libraryView .resource-card { border-radius: 16px; }
#libraryView .card-body { padding: 15px; }
#libraryView .card-body h3 { min-height: 2.8em; margin: 7px 0; font-size: clamp(17px, .7vw, 26px); line-height: 1.4; }
#libraryView .card-body > p { min-height: 3.2em; margin-bottom: 10px; font-size: var(--home-text-size, 14px); -webkit-line-clamp: 2; }
#libraryView .tag-row { flex-wrap: nowrap; min-height: 26px; overflow: hidden; }
#libraryView .tag-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#libraryView .tag-row span:nth-child(n+4), #libraryView .method-tags, #libraryView .ability-row { display: none; }
#libraryView .card-actions { gap: 8px; margin-top: 12px; padding-top: 10px; }
#libraryView .resource-context { min-width: 0; }
#libraryView .card-open { flex: none; min-height: 44px; font-size: var(--home-text-size, 14px); }
#libraryView .lab-code.is-featured { color: #fff; background: #426ce9; border-color: transparent; }
#libraryView .method-panel { max-width: none; margin: 0; padding: 0; }
#libraryView .method-summary { min-height: 62px; padding: 12px 18px; }
#libraryView .curriculum-map-entry { max-width: none; margin: 16px 0 0; }
#libraryView .teacher-cta { max-width: none; margin: 28px 0; }

/* The rail, header and resources share one fluid frame on desktop and boards. */
@media (min-width: 761px) {
  body.home-layout-active #libraryView { width: calc(100% - var(--home-start) - var(--home-gutter)); margin-left: var(--home-start); margin-right: var(--home-gutter); }
  body.home-layout-active .topbar { padding-left: var(--home-start); padding-right: var(--home-gutter); }
  body.home-layout-active .brand strong { font-size: clamp(18px, .75vw, 26px); }
  body.home-layout-active .brand small { font-size: clamp(11px, .45vw, 16px); }
  body.home-layout-active .top-actions > * { min-height: 44px; font-size: var(--home-text-size); }
  body.home-layout-active .tool-rail,
  body.home-layout-active .tool-rail:hover,
  body.home-layout-active .tool-rail:focus-within { left: var(--home-gutter); width: var(--home-tool-width); padding: 10px; max-height: calc(100vh - 110px); overflow-y: auto; transition: border-color .22s ease, box-shadow .22s ease; }
  body.home-layout-active .tool-rail-title { display: flex; align-items: center; padding: 5px 6px 10px; }
  body.home-layout-active .tool-rail-title span { font-size: var(--home-text-size); }
  body.home-layout-active .tool-rail-title small,
  body.home-layout-active .tool-rail-more,
  body.home-layout-active .tool-rail::after { display: none; }
  body.home-layout-active .tool-rail nav { display: grid; gap: 6px; margin-top: 8px; }
  body.home-layout-active .tool-rail-item,
  body.home-layout-active .tool-rail:hover .tool-rail-item,
  body.home-layout-active .tool-rail:focus-within .tool-rail-item { flex-direction: row; justify-content: flex-start; gap: 7px; min-height: 54px; padding: 6px 4px; animation: none; }
  body.home-layout-active .tool-rail-copy { display: block; min-width: 0; }
  body.home-layout-active .tool-rail-copy strong { font-size: clamp(12px, .48vw, 18px); }
  body.home-layout-active .tool-rail-copy small { display: block; max-height: none; opacity: 1; margin-top: 3px; font-size: clamp(9px, .38vw, 14px); }
  body.home-layout-active .tool-rail-icon { flex: 0 0 clamp(32px, 1.2vw, 44px); width: clamp(32px, 1.2vw, 44px); height: clamp(32px, 1.2vw, 44px); font-size: clamp(16px, .6vw, 22px); }
  #libraryView .hero-copy h1 { font-size: clamp(26px, 1.1vw, 40px); }
  #libraryView .hero-copy .hero-lead, #libraryView .hero-total, #libraryView .hero-text-button { font-size: var(--home-text-size); }
  #libraryView .hero-text-button { min-height: 38px; }
  #libraryView .filter-chip, #libraryView .topic-filter { min-height: 38px; font-size: var(--home-text-size); }
  #libraryView .filter-row > b { flex-basis: 2.5em; width: auto; white-space: nowrap; font-size: var(--home-text-size); }
  #libraryView .learning-route button { min-height: 40px; }
  #libraryView .learning-route strong, #libraryView .sort-switch button { font-size: var(--home-text-size); }
  #libraryView .sort-switch button, #libraryView .reset-filters { min-height: 38px; }
  #libraryView .resource-kicker, #libraryView .resource-context, #libraryView .tag-row span { font-size: clamp(12px, .5vw, 18px); }
}
@media (min-width: 1800px) {
  #libraryView .resource-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
}
@media (min-width: 2400px) {
  #libraryView .resource-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px; }
  #libraryView .card-body { padding: 20px; }
  #libraryView .resource-heading h2 { font-size: clamp(26px, 1vw, 36px); }
  #libraryView #searchResultStatus, #libraryView .reset-filters { font-size: 16px; }
  #libraryView .course-showcase { grid-template-columns: 180px minmax(0, 1fr); }
  #libraryView .showcase-cover { width: 180px; }
  #libraryView .showcase-course-copy > strong { font-size: clamp(18px, .7vw, 26px); }
  #libraryView .showcase-head strong, #libraryView .showcase-course-copy > span,
  #libraryView .showcase-duration strong, #libraryView .showcase-explore { font-size: 14px; }
  #libraryView .searchbox { min-height: 54px; }
  #libraryView .searchbox input { font-size: 20px; }
}
@media (min-width: 761px) and (max-width: 1199px) {
  #libraryView .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.home-layout-active .topbar { padding-inline: var(--home-gutter); }
  body.home-layout-active .brand small { display: none; }
  body.home-layout-active .menu-toggle { display: flex; align-items: center; gap: 5px; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
  body.home-layout-active .menu-toggle span { display: block; width: 16px; border-top: 2px solid #52617e; }
  body.home-layout-active .menu-toggle b { margin-left: 3px; font-size: 14px; }
  body.home-layout-active .top-actions { display: none; position: absolute; left: var(--home-gutter); right: var(--home-gutter); top: calc(100% - 4px); padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
  body.home-layout-active .top-actions.is-open { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.home-layout-active .top-actions > * { justify-content: center; margin: 0; }
}
@media (max-width: 1100px) and (min-width: 761px) {
  #libraryView .library-hero { grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); gap: 16px; padding: 14px 16px; }
  #libraryView .hero-copy h1 { font-size: 23px; }
  #libraryView .hero-copy .hero-actions { gap: 10px; }
  #libraryView .hero-total { font-size: 10px; }
  #libraryView .course-showcase { grid-template-columns: 100px minmax(0, 1fr); column-gap: 10px; }
  #libraryView .showcase-cover { width: 100px; }
  #libraryView .showcase-explore { display: none; }
  #libraryView .showcase-course-copy > strong { font-size: 12px; }
}
@media (max-width: 760px) {
  #libraryView { width: calc(100% - 32px); margin: 0 16px; }
  #libraryView .library-hero { grid-template-columns: 1fr; min-height: 0; gap: 9px; margin: 10px 0 12px; padding: 12px 14px; border-radius: 14px; }
  #libraryView .hero-copy h1 { font-size: 23px; line-height: 1.3; }
  #libraryView .hero-copy .hero-lead { margin: 3px 0 0; font-size: 11px; }
  #libraryView .hero-copy .hero-actions { display: none; }
  #libraryView .course-showcase { grid-template-columns: 84px minmax(0, 1fr); grid-template-rows: auto auto 9px; column-gap: 10px; row-gap: 1px; padding-top: 8px; border-top: 1px solid #dce6fa; }
  #libraryView .showcase-cover { width: 84px; border-radius: 8px; }
  #libraryView .showcase-cover-inner { border-radius: 8px; }
  #libraryView .showcase-head strong { font-size: 10px; }
  #libraryView .showcase-course-copy > span, #libraryView .showcase-duration { display: none; }
  #libraryView .showcase-course-copy > strong { font-size: 12px; line-height: 1.45; }
  #libraryView .search-panel { padding-bottom: 10px; }
  #libraryView .searchbox { min-height: 43px; padding-inline: 12px; gap: 9px; }
  #libraryView .searchbox input { font-size: 13px; }
  #libraryView .filter-row { gap: 7px; margin-top: 7px; }
  #libraryView .filter-row > b { flex-basis: 28px; width: 28px; font-size: 11px; }
  #libraryView .quick-filters { flex-wrap: nowrap; gap: 5px; }
  #libraryView #gradeFilters, #libraryView .filter-options { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #libraryView #domainFilters { overflow: visible; flex: none; }
  #libraryView .filter-chip { min-height: 30px; padding: 4px 10px; font-size: 11px; }
  #libraryView .topic-filter { font-size: 10px; }
  #libraryView .resource-heading { margin-bottom: 8px; }
  #libraryView .resource-heading > div { gap: 8px; }
  #libraryView .resource-heading .gallery-controls { gap: 4px; }
  #libraryView .reset-label { display: none; }
  #libraryView .reset-filters { min-width: 28px; min-height: 30px; justify-content: center; font-size: 16px; }
  #libraryView .resource-heading h2 { font-size: 20px; }
  #libraryView #searchResultStatus, #libraryView .reset-filters { font-size: 10px; }
  #libraryView .learning-route { gap: 5px; margin: 0 0 8px; }
  #libraryView .learning-route button { min-height: 32px; padding: 5px 10px; }
  #libraryView .learning-route strong { font-size: 11px; }
  #libraryView .sort-switch button { padding: 4px 7px; font-size: 10px; }
  #libraryView .method-summary { min-height: 62px; padding: 12px; }
  #libraryView .curriculum-map-entry { padding: 22px; }
  #libraryView .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #libraryView .card-body h3 { font-size: 17px; }
}
@media (max-width: 600px) {
  #libraryView .resource-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 761px) and (any-pointer: coarse) {
  body.home-layout-active .top-actions > *,
  #libraryView .filter-chip, #libraryView .topic-filter,
  #libraryView .learning-route button, #libraryView .sort-switch button,
  #libraryView .reset-filters, #libraryView .hero-text-button, #libraryView .card-open { min-height: 48px; }
  #libraryView .course-showcase { grid-template-rows: auto auto 28px; }
  #libraryView .showcase-pagination { gap: 2px; }
  #libraryView .showcase-pagination button,
  #libraryView .showcase-pagination button.is-active { position: relative; flex-basis: 28px; width: 28px; height: 28px; border: 0; border-radius: 0; background: transparent; }
  #libraryView .showcase-pagination button::after { content: ""; position: absolute; width: 6px; height: 6px; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 99px; background: #d1daec; }
  #libraryView .showcase-pagination button.is-active::after { width: 15px; background: var(--blue); }
}
@media (max-width: 360px) {
  body:has(#libraryView.active) { min-width: 0; }
  #libraryView .resource-heading { flex-wrap: wrap; }
  #libraryView .resource-heading .gallery-controls { margin-left: auto; }
}

/* Keep the selected search scope readable and removable on every screen. */
#libraryView .filter-row > b,
#libraryView .learning-stage-label {
  flex: 0 0 4.5em;
  width: 4.5em;
  color: #6b7892;
  font-size: var(--home-text-size, 14px);
  white-space: nowrap;
}
#libraryView .learning-stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}
#libraryView .learning-stage-row .learning-route {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 3px;
}
#libraryView .learning-route [data-stage-filter="extension"] {
  border-style: dashed;
}
#libraryView .learning-route [data-stage-filter="extension"].is-active {
  border-style: solid;
}
#libraryView .active-filter-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 0 0 14px;
  min-width: 0;
  color: #61718d;
  font-size: var(--home-text-size, 14px);
}
#libraryView .filter-summary-label { flex: none; font-weight: 600; }
#libraryView .active-filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
#libraryView .active-filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  max-width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid #cbd8f8;
  border-radius: 9px;
  background: #edf3ff;
  color: #3155a5;
  font-size: inherit;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
}
#libraryView .active-filter-chip > span:first-child { min-width: 0; overflow-wrap: anywhere; }
#libraryView .active-filter-chip > span[aria-hidden] { flex: none; font-size: 18px; line-height: 1; }
#libraryView .active-filter-chip:hover { background: #e1ebff; border-color: #a9bff2; }
#libraryView .filter-clear-all {
  flex: none;
  min-height: 36px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4264a4;
  font-size: inherit;
  cursor: pointer;
}
#libraryView .filter-clear-all:hover { background: #edf3ff; }
#libraryView .filter-summary-default { margin: 0; color: #71809a; }
#libraryView .empty-state { padding: 34px 24px; }
#libraryView .filter-empty-title { display: block; font-size: 20px; line-height: 1.5; }
#libraryView .empty-state p { margin: 10px 0; line-height: 1.7; overflow-wrap: anywhere; }
#libraryView .filter-empty-context { color: #536787; }
#libraryView .filter-empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
#libraryView .filter-empty-actions button {
  max-width: 100%;
  min-height: 44px;
  padding: 9px 15px;
  font-size: 14px;
  white-space: normal;
}

/* Course facts come from saved metadata and can be absent or span several grades. */
#libraryView .cover .badge { max-width: 57%; white-space: normal; text-align: right; line-height: 1.45; }
#libraryView .lab-code { max-width: 48%; overflow-wrap: anywhere; }
#libraryView .resource-kicker { flex-wrap: wrap; gap: 4px 10px; }
#libraryView .resource-kicker b { white-space: normal; }
#libraryView .resource-context { white-space: normal; }
@media (max-width: 760px) {
  #libraryView .filter-row > b,
  #libraryView .learning-stage-label { flex-basis: 4.5em; width: 4.5em; font-size: 12px; }
  #libraryView .learning-stage-row { gap: 7px; margin-bottom: 8px; }
  #libraryView .active-filter-summary { gap: 6px 8px; font-size: 12px; }
  #libraryView .active-filter-chips { gap: 6px; }
  #libraryView .active-filter-chip,
  #libraryView .filter-clear-all { min-height: 44px; }
  #libraryView .empty-state { padding: 26px 16px; }
  #libraryView .filter-empty-title { font-size: 18px; }
  #libraryView .empty-state p { font-size: 13px; }
  #libraryView .filter-empty-actions { gap: 8px; }
}
