.library-search-shell {
  --library-search-sticky-offset: calc(var(--shared-header-height, 64px) + var(--space-1));
  --library-search-action-control-width: 112px;
  --library-search-action-control-height: 36px;
  --library-search-input-control-height: 46px;
  --library-search-select-chevron-color: #2f2b25;
  display: grid;
  gap: var(--space-3);
  grid-column: 1 / -1;
  color-scheme: light;
}

.library-search-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.library-search-mode-tabs__item {
  width: auto;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--ui-button-border);
  border-radius: 0;
  background: var(--ui-button-surface);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  font-weight: var(--ui-weight-medium);
  line-height: 1.2;
  white-space: nowrap;
}

.library-search-mode-tabs__item:hover,
.library-search-mode-tabs__item:focus-visible {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-button-surface-hover);
}

.library-search-mode-tabs__item.is-active {
  border-color: var(--ui-border-strong);
  background: var(--ui-surface-muted);
  color: var(--ui-text-strong);
}

.library-search-mode-panel {
  display: none;
  min-width: 0;
}

.library-search-mode-panel.is-active {
  display: grid;
  gap: var(--space-3);
}

.library-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: stretch;
  min-width: 0;
  padding-bottom: var(--space-1);
}

.library-search-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: var(--library-search-input-control-height);
  min-height: var(--library-search-input-control-height);
  border-radius: 0;
}

.library-search-input {
  border: 1px solid var(--ui-border-hover);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: var(--ui-line-body);
}

.library-search-submit,
.library-search-reset {
  width: auto;
  border-radius: 0;
  white-space: nowrap;
}

.library-search-submit {
  box-sizing: border-box;
  min-height: var(--library-search-input-control-height);
  height: var(--library-search-input-control-height);
  min-width: var(--library-search-action-control-width);
}

.library-search-submit {
  border: 1px solid var(--ui-button-border);
  background: var(--ui-button-surface);
  color: var(--ui-text-strong);
}

.library-search-submit:hover,
.library-search-submit:focus-visible {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-button-surface-hover);
}

.library-search-form--qa {
  max-width: 860px;
  gap: var(--space-1);
  padding-bottom: 0;
}

.library-search-form--qa .library-search-submit {
  min-width: 72px;
  padding-left: 16px;
  padding-right: 16px;
}

.library-search-reset {
  justify-self: start;
  min-height: 36px;
  background: var(--ui-button-surface);
  border-color: var(--ui-button-border);
  color: var(--ui-text);
}

.library-search-layout {
  display: grid;
  grid-template-columns: minmax(224px, 2.5fr) minmax(0, 9.5fr);
  gap: var(--space-2);
  align-items: start;
  min-height: 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--ui-divider);
  overflow: visible;
}

.library-search-pane {
  min-height: 0;
}

.library-search-filters {
  min-width: 0;
  align-self: start;
}

.library-search-sidebar {
  position: sticky;
  top: var(--library-search-sticky-offset);
  max-height: calc(100vh - var(--library-search-sticky-offset) - var(--space-2));
  overflow-y: auto;
  overscroll-behavior-y: auto;
  scrollbar-gutter: stable;
  box-sizing: border-box;
  padding-inline-end: var(--space-2);
}

.library-search-filter-details {
  padding: 0 0 var(--space-3);
}

.library-search-filter-details summary {
  display: flex;
  align-items: center;
  min-height: 38px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: var(--ui-font-size-base);
  font-weight: var(--ui-weight-bold);
  color: var(--ui-text-strong);
}

.library-search-filter-body {
  display: grid;
  gap: 14px;
  padding-top: var(--space-2);
}

.library-search-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-search-field--select,
.library-search-sort {
  position: relative;
}

.library-search-field input,
.library-search-field select,
.library-search-sort select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border-radius: 0;
  border-color: var(--ui-border-hover);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
}

.library-search-field select,
.library-search-sort select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: calc(var(--space-3) + 12px);
}

.library-search-field input[type="number"] {
  color-scheme: light;
}

.library-search-results-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--space-2);
  min-width: 0;
  align-self: start;
}

.library-search-results-topline {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 38px;
}

.library-search-summary {
  min-width: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  font-weight: var(--ui-weight-bold);
  line-height: var(--ui-line-muted);
}

.library-search-sort {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  white-space: nowrap;
}

.library-search-field--select::after,
.library-search-sort::after {
  content: "";
  position: absolute;
  right: 12px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--library-search-select-chevron-color);
  border-bottom: 1.5px solid var(--library-search-select-chevron-color);
  pointer-events: none;
  transform: rotate(45deg);
}

.library-search-field--select::after {
  bottom: 15px;
}

.library-search-sort::after {
  top: 50%;
  transform: translateY(-70%) rotate(45deg);
}

.library-search-sort select {
  width: var(--library-search-action-control-width);
  min-height: var(--library-search-action-control-height);
  height: var(--library-search-action-control-height);
  max-width: none;
}

.library-search-status {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: var(--ui-line-body);
}

.library-search-results {
  display: grid;
  gap: 0;
}

.library-search-facet-summary {
  display: grid;
  gap: 14px;
}

.library-qa-status {
  min-height: 1.5em;
}

.library-qa-results,
.library-qa-results__list {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.library-qa-results__summary {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-qa-card {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--ui-divider);
}

.library-qa-card:first-child {
  padding-top: 0;
}

.library-qa-card__header {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
}

.library-qa-card__heading {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.library-qa-card__heading h2 {
  margin: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: var(--ui-weight-medium);
  line-height: 1.32;
}

.library-qa-card__authors,
.library-qa-card__location {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-qa-card__items {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-qa-card__item {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.library-qa-card__snippet {
  margin: 0;
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: 1.68;
}

.library-qa-card__snippet mark {
  background: rgba(182, 90, 42, 0.12);
  color: var(--ui-text-strong);
  padding: 0 1px;
}

.library-search-facet-groups {
  display: grid;
  gap: 14px;
}

.library-search-facet-group {
  display: grid;
  gap: 8px;
}

.library-search-facet-group__title {
  margin: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  font-weight: var(--ui-weight-bold);
  line-height: var(--ui-line-tight);
}

.library-search-facet-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-search-facet-item {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-body);
  text-align: left;
  cursor: pointer;
}

.library-search-facet-item:hover,
.library-search-facet-item:focus-visible {
  color: var(--ui-text-strong);
}

.library-search-facet-item.is-active {
  color: var(--ui-text-strong);
  font-weight: var(--ui-weight-bold);
}

.library-search-facet-item__label {
  min-width: 0;
}

.library-search-facet-item__count {
  flex-shrink: 0;
  color: var(--ui-text-muted);
  font-variant-numeric: tabular-nums;
}

.library-search-pagination {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.library-search-load-more {
  width: auto;
  min-height: 40px;
  border-radius: 0;
  white-space: nowrap;
}

.library-search-result {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) minmax(112px, auto);
  gap: var(--space-2);
  align-items: start;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--ui-divider);
}

.library-search-result__cover {
  width: 84px;
  min-width: 0;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background: var(--mz-cover-placeholder, #e9dfcc);
  border: none;
  color: var(--ui-text-muted);
  font-family: var(--font-heading);
  text-align: center;
  flex-shrink: 0;
  border-radius: 0;
}

.library-search-result__cover:has(img) {
  background: transparent;
}

.library-search-result__cover img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  border: 1px solid var(--mz-rule);
  border-radius: 0;
}

.library-search-result__cover-placeholder {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 8px;
}

.library-search-result__cover-mark {
  color: var(--ui-text-strong);
  font-size: var(--ui-font-size-sm);
  font-weight: var(--ui-weight-bold);
  line-height: 1;
}

.library-search-result__cover-label {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-xs);
  font-weight: var(--ui-weight-medium);
  line-height: var(--ui-line-tight);
}

.library-search-result__body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.library-search-result__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.library-search-result__title {
  margin: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: var(--ui-weight-medium);
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-search-result__meta,
.library-search-result__location,
.library-search-facet-summary {
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-md);
  line-height: 1.5;
}

.library-search-result__meta {
  color: var(--ui-text);
}

.library-search-result__location {
  color: var(--ui-text-strong);
  font-weight: var(--ui-weight-medium);
}

.library-search-result__snippet {
  margin: 0;
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: 1.68;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-search-result__snippet mark {
  background: rgba(182, 90, 42, 0.12);
  color: var(--ui-text-strong);
  padding: 0 1px;
}

.library-search-result__note {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-search-result__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 112px;
}

.library-search-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto;
  min-height: var(--library-search-action-control-height);
  padding: 0 12px;
  border: 1px solid var(--ui-button-border);
  border-radius: 0;
  background: var(--ui-button-surface);
  color: var(--ui-link);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  font-weight: var(--ui-weight-medium);
  line-height: 1.2;
  white-space: nowrap;
}

.library-search-result__actions .library-search-action {
  width: 100%;
}

.library-search-action--primary {
  color: var(--ui-text-strong);
}

.library-search-action:hover,
.library-search-action:focus-visible {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-button-surface-hover);
}

.library-search-action.is-saved {
  border-color: var(--ui-chip-border);
  background: var(--ui-chip-surface);
  color: var(--ui-text-strong);
}

.library-search-action:disabled {
  cursor: default;
  opacity: 0.68;
}

.library-related-panel {
  display: grid;
  grid-column: 2 / 4;
  grid-template-columns: minmax(0, 1fr) minmax(112px, auto);
  column-gap: var(--space-2);
  row-gap: var(--space-2);
  align-items: start;
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--ui-divider);
}

.library-related-panel__topline {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  min-width: 0;
}

.library-related-panel__body {
  grid-column: 1 / -1;
  min-width: 0;
}

.library-related-panel__actions {
  display: flex;
  grid-column: 2;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 112px;
}

.library-related-panel__actions {
  grid-row: 1;
}

.library-related-panel__actions .library-search-action,
.library-related-panel__item .library-search-action {
  width: 100%;
}

.library-related-panel__topline h3,
.library-related-panel__item h3 {
  margin: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-heading);
  font-size: var(--ui-font-size-base);
  line-height: var(--ui-line-tight);
}

.library-related-panel__list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-related-panel__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, auto);
  gap: var(--space-2);
  align-items: start;
}

.library-related-panel__book {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.library-related-panel__meta,
.library-related-panel__empty,
.library-related-panel__loading,
.library-related-panel__error {
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-related-panel__reasons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.library-citation-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  background: var(--ui-backdrop, rgba(28, 24, 20, 0.42));
}

.library-citation-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--space-2);
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - var(--space-4)));
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--ui-border-strong);
  border-radius: 0;
  background: var(--ui-surface-solid);
  color: var(--ui-text);
}

.library-citation-modal__header {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: var(--space-2) var(--space-2) 0;
}

.library-citation-modal__header h2,
.library-citation-modal__row h3 {
  margin: 0;
  color: var(--ui-text-strong);
  font-family: var(--font-heading);
  line-height: var(--ui-line-tight);
}

.library-citation-modal__header h2 {
  font-size: var(--ui-font-size-xl);
}

.library-citation-modal__row h3 {
  font-size: var(--ui-font-size-base);
}

.library-citation-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--ui-button-border);
  border-radius: 0;
  background: var(--ui-button-surface);
  color: var(--ui-text-strong);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-lg);
}

.library-citation-modal__close:hover,
.library-citation-modal__close:focus-visible {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-button-surface-hover);
}

.library-citation-modal__scope {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 0 var(--space-2);
}

.library-citation-modal__scope-option {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ui-button-border);
  border-radius: 0;
  background: var(--ui-button-surface);
  color: var(--ui-text-strong);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  white-space: nowrap;
}

.library-citation-modal__scope-option:hover,
.library-citation-modal__scope-option:focus-visible {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-button-surface-hover);
}

.library-citation-modal__scope-option.is-active {
  border-color: var(--ui-button-border-hover);
  background: var(--ui-surface-muted);
  color: var(--ui-text-strong);
}

.library-citation-modal__scope-option:disabled {
  opacity: 0.52;
}

.library-citation-modal__body {
  min-width: 0;
  overflow-y: auto;
  padding: 0 var(--space-2) var(--space-2);
}

.library-citation-modal__context,
.library-citation-modal__loading,
.library-citation-modal__error {
  margin: 0;
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-citation-modal__context {
  margin-bottom: var(--space-1);
}

.library-citation-modal__warning {
  margin: 0;
  color: var(--ui-warning, var(--ui-text-muted));
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-sm);
  line-height: var(--ui-line-muted);
}

.library-citation-modal__error {
  color: var(--ui-danger, var(--ui-text-muted));
}

.library-citation-modal__rows {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.library-citation-modal__row {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--ui-divider);
}

.library-citation-modal__row:first-child {
  padding-top: 0;
  border-top: 0;
}

.library-citation-modal__row-head {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.library-citation-modal__copy {
  min-height: 32px;
  color: var(--ui-text-strong);
}

.library-citation-modal__text {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ui-text-strong);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: var(--ui-line-body);
}

.library-search-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--ui-divider);
  border-radius: 0;
  background: var(--ui-surface-solid);
  color: var(--ui-text-soft);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-xs);
  font-weight: var(--ui-weight-medium);
  line-height: var(--ui-line-tight);
}

.library-search-state {
  display: grid;
  gap: var(--space-2);
  max-width: 680px;
  padding: var(--space-3) 0;
}

.library-search-state h2 {
  margin: 0;
  color: var(--ui-text-strong);
  font-size: var(--ui-font-size-xl);
  line-height: var(--ui-line-tight);
}

.library-search-state p {
  margin: 0;
  color: var(--ui-text-muted);
  font-family: var(--font-ui);
  font-size: var(--ui-font-size-base);
  line-height: var(--ui-line-body);
}

.library-search-state__actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  align-items: center;
}

.library-search-facet-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-search-facet-list li {
  display: flex;
  gap: var(--space-1);
  justify-content: space-between;
  min-width: 0;
}

@media (max-width: 900px) {
  .library-search-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .library-search-pane {
    overflow: visible;
  }

  .library-search-sidebar {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
    padding-inline-end: 0;
  }

  .library-search-result {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .library-search-result__cover {
    width: 76px;
  }

  .library-search-result__actions {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
  }

  .library-search-filter-details {
    padding: var(--space-2) 0;
  }

  .library-related-panel {
    grid-column: 2;
    grid-template-columns: 1fr;
  }

  .library-related-panel__body,
  .library-related-panel__actions {
    grid-column: 1;
    grid-row: auto;
  }

  .library-related-panel__actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .library-search-form {
    grid-template-columns: 1fr;
  }

  .library-search-mode-tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .library-search-mode-tabs__item {
    width: 100%;
  }

  .library-search-result {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
  }

  .library-search-result__cover {
    width: 56px;
  }

  .library-search-result__cover-placeholder {
    padding: 6px;
  }

  .library-search-result__cover-label {
    display: none;
  }

  .library-search-result__title {
    font-size: var(--ui-font-size-lg);
  }

  .library-search-result__meta,
  .library-search-result__location,
  .library-search-facet-summary {
    font-size: var(--ui-font-size-sm);
  }

  .library-search-result__snippet {
    font-size: var(--ui-font-size-md);
    line-height: 1.6;
  }

  .library-search-submit {
    width: 100%;
  }

  .library-search-form--qa {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .library-search-form--qa .library-search-submit {
    width: auto;
  }

  .library-search-load-more {
    width: 100%;
  }

  .library-search-results-topline {
    align-items: stretch;
    flex-direction: column;
  }

  .library-search-sort {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 180px);
    justify-content: space-between;
    width: 100%;
  }

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

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

  .library-related-panel {
    grid-column: 1 / -1;
  }

  .library-citation-modal-backdrop {
    align-items: stretch;
    padding: 12px;
  }

  .library-citation-modal {
    max-height: calc(100vh - 24px);
  }

  .library-citation-modal__header,
  .library-citation-modal__scope,
  .library-citation-modal__body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .library-citation-modal__row-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .library-search-sort select {
    width: 100%;
    max-width: none;
  }

  .library-search-result__actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .library-search-action {
    width: auto;
    min-height: 34px;
    white-space: normal;
  }

  .library-search-result__actions .library-search-action {
    width: auto;
  }
}

/* ------------------------------------------------------------------------------------------ */
/* Tra cứu toàn văn nhóm theo sách — route v2 (FULLTEXT-WEB-1; DAC-TA-WEB §7.3.1–7.3.4, §7.3.6). */
/* Kẻ mảnh, góc vuông, không bóng, không nền màu cho khối trạng thái. Màu theo --mz-* (sáng,     */
/* tối, quốc tang); tô từ khoá theo token search-highlight.                                      */
/* ------------------------------------------------------------------------------------------ */
.library-search-shell {
  --lsv2-hl: #f2d88a;
  --lsv2-strong: #1a120d;
  --lsv2-surface: var(--mz-paper-deep, #f6efe2);
  --lsv2-danger: #b3261e;
  --lsv2-control: #847d77;
}
html[data-mz-theme="dark"] .library-search-shell { --lsv2-hl: #5a4721; --lsv2-strong: #faf3e6; --lsv2-danger: #f2b8b5; --lsv2-control: #b08d4a; }
body.theme-quoc-tang .library-search-shell { --lsv2-hl: #d6d6d6; --lsv2-strong: #111111; --lsv2-control: #8a8a8a; }
html[data-mz-theme="dark"] body.theme-quoc-tang .library-search-shell { --lsv2-hl: #474747; --lsv2-strong: #f2f2f2; --lsv2-control: #7a7a7a; }

.library-search-shell .lsv2-ico { width: 24px; height: 24px; flex: none; fill: currentColor; }
.library-search-shell .lsv2-ico--sm { width: 16px; height: 16px; }
.library-search-shell [hidden] { display: none !important; }

.library-search-shell .library-search-form { position: relative; }
.library-search-shell .lsv2-is-loading::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -6px;
  height: 3px;
  background: var(--mz-red, #8f131a);
  animation: lsv2-run 1.2s linear infinite;
}
@keyframes lsv2-run { 0% { left: 0; right: 100%; } 50% { left: 25%; right: 35%; } 100% { left: 100%; right: 0; } }
@media (prefers-reduced-motion: reduce) { .library-search-shell .lsv2-is-loading::after { animation: none; left: 0; right: 0; } }

.library-search-shell .lsv2-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: -4px 0 0;
  color: var(--mz-muted);
  font: italic 400 13.5px/20px var(--mz-serif);
}
.library-search-shell .lsv2-hint .lsv2-ico { margin-top: 2px; }

.library-search-shell .library-search-summary {
  color: var(--mz-muted);
  font: 700 13px/18px var(--mz-condensed);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.library-search-shell .library-search-summary b { color: var(--lsv2-strong); }

.library-search-shell .lsv2-loading__text { margin: 0 0 12px; color: var(--mz-muted); font: italic 400 14px/20px var(--mz-serif); }
.library-search-shell .lsv2-skeleton { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--mz-rule); }
.library-search-shell .lsv2-skeleton__cover { display: block; height: 96px; background: var(--lsv2-surface); }
.library-search-shell .lsv2-skeleton__lines { display: grid; gap: 10px; align-content: start; }
.library-search-shell .lsv2-skeleton__lines i { display: block; height: 12px; background: var(--lsv2-surface); }
.library-search-shell .lsv2-skeleton__lines i:nth-child(1) { width: 52%; }
.library-search-shell .lsv2-skeleton__lines i:nth-child(2) { width: 34%; }
.library-search-shell .lsv2-skeleton__lines i:nth-child(3) { width: 90%; margin-top: 12px; }
.library-search-shell .lsv2-skeleton__lines i:nth-child(4) { width: 78%; }

/* Nhóm theo sách (§7.3.2) */
.library-search-shell .lsv2-group { padding: 24px 0 8px; border-bottom: 1px solid var(--mz-rule); }
.library-search-shell .lsv2-group__head { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 20px; align-items: start; }
.library-search-shell .lsv2-cover { display: flex; align-items: flex-end; width: 72px; aspect-ratio: 2 / 3; text-decoration: none; }
.library-search-shell .lsv2-cover img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: bottom; border: 1px solid var(--mz-rule); background: var(--mz-cover-placeholder, #e9dfcc); }
.library-search-shell .lsv2-cover__ph { display: grid; place-items: center; width: 100%; height: 100%; border: 1px solid var(--mz-rule); background: var(--mz-cover-placeholder, #e9dfcc); color: var(--mz-muted); font: 700 14px/1 var(--mz-condensed); }
.library-search-shell .lsv2-group__meta { min-width: 0; }
.library-search-shell .lsv2-kicker { margin: 0 0 4px; color: var(--mz-red); font: 700 12px/16px var(--mz-condensed); letter-spacing: 0.12em; text-transform: uppercase; }
.library-search-shell .lsv2-title { margin: 0; font: 700 19px/25px var(--mz-serif); letter-spacing: 0; text-transform: none; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.library-search-shell .lsv2-title a { color: var(--lsv2-strong); text-decoration: none; }
.library-search-shell .lsv2-title a:hover { color: var(--mz-red); }
.library-search-shell .lsv2-author { margin: 4px 0 0; color: var(--mz-red); font: 700 12px/16px var(--mz-condensed); letter-spacing: 0.08em; text-transform: uppercase; }
.library-search-shell .lsv2-count { margin: 6px 0 0; color: var(--mz-muted); font: italic 400 14px/20px var(--mz-serif); }
.library-search-shell .lsv2-count b { color: var(--lsv2-strong); font-style: normal; }
.library-search-shell .lsv2-hits { margin: 14px 0 0 92px; padding: 0; list-style: none; }
.library-search-shell .lsv2-hit { padding: 14px 0; border-top: 1px solid var(--mz-rule); }
.library-search-shell .lsv2-snippet {
  max-width: 72ch;
  margin: 0;
  color: var(--mz-ink);
  font: 400 15px/24px var(--mz-serif);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.library-search-shell .lsv2-snippet mark {
  padding: 0 1px;
  border-radius: 0;
  background: var(--lsv2-hl);
  color: var(--lsv2-strong);
  font-weight: 700;
}
.library-search-shell .lsv2-loc {
  display: flex;
  gap: 4px;
  min-width: 0;
  margin: 4px 0 0;
  color: var(--mz-muted);
  font: 400 13px/18px var(--mz-condensed);
}
.library-search-shell .lsv2-loc b { flex: none; font-weight: 700; }
.library-search-shell .lsv2-loc span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-search-shell .lsv2-actions,
.library-search-shell .lsv2-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; margin-top: 8px; }
.library-search-shell .lsv2-foot { margin: 0 0 0 92px; padding: 10px 0 8px; border-top: 1px solid var(--mz-rule); }
.library-search-shell .lsv2-foot--plain { border-top: 0; padding-top: 6px; }
.library-search-shell .lsv2-foot__note { color: var(--mz-muted); font: italic 400 13px/20px var(--mz-serif); }
.library-search-shell .lsv2-act.lsv2-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mz-ink);
  font: 700 12.5px/16px var(--mz-condensed);
  letter-spacing: 0.1em;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: none;
  cursor: pointer;
}
.library-search-shell .lsv2-act > span,
.library-search-shell a.lsv2-act { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.library-search-shell .lsv2-act--primary.lsv2-act--primary { color: var(--mz-red); }
.library-search-shell .lsv2-act:hover { color: var(--mz-red); }
.library-search-shell .lsv2-act.is-saved { color: var(--mz-red); }
.library-search-shell .lsv2-gated-note { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--mz-rule-strong); color: var(--mz-muted); font: italic 400 14px/20px var(--mz-serif); }
.library-search-shell .lsv2-inline-error { display: flex; align-items: center; gap: 6px; margin: 8px 0; color: var(--lsv2-danger); font: 400 14px/20px var(--mz-serif); }
.library-search-shell .lsv2-group .lsv2-inline-error { margin-left: 92px; }

/* Tải tiếp nhóm sách */
.library-search-shell .lsv2-more { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 28px 0 8px; }
.library-search-shell .lsv2-more__note { color: var(--mz-muted); font: italic 400 14px/20px var(--mz-serif); }

/* Khối trạng thái (§7.3.4) */
.library-search-shell .lsv2-state { display: flex; gap: 14px; margin: 8px 0 16px; padding: 22px 0; border-top: 1px solid var(--mz-rule); border-bottom: 1px solid var(--mz-rule); }
.library-search-shell .lsv2-state__ico { margin-top: 1px; color: var(--mz-muted); } /* tâm khoá = tâm chữ hoa dòng tiêu đề đầu (18px/26px) */
.library-search-shell .lsv2-state__body { display: grid; gap: 4px; min-width: 0; }
.library-search-shell .lsv2-state__title { margin: 0; color: var(--lsv2-strong); font: 700 18px/26px var(--mz-serif); letter-spacing: 0; text-transform: none; }
.library-search-shell .lsv2-state__text { margin: 0; color: var(--mz-ink); font: 400 15px/24px var(--mz-serif); }
.library-search-shell .lsv2-state__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; margin-top: 14px; }
.library-search-shell .lsv2-btn.lsv2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid var(--mz-red-fill, var(--mz-red));
  border-radius: 0;
  background: var(--mz-red-fill, var(--mz-red));
  color: var(--mz-on-red);
  font: 700 13px/16px var(--mz-condensed);
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: none;
  cursor: pointer;
}
.library-search-shell .lsv2-btn--outline.lsv2-btn--outline { border-color: var(--mz-ink); background: transparent; color: var(--mz-ink); }
.library-search-shell .lsv2-btn--outline.lsv2-btn--outline:hover { border-color: var(--mz-red); color: var(--mz-red); }
.library-search-shell .lsv2-btn--text.lsv2-btn--text { min-height: 36px; padding: 0; border-color: transparent; background: transparent; color: var(--mz-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.library-search-shell .lsv2-btn[aria-disabled="true"] { opacity: 0.42; cursor: default; }

/* Danh mục theo id từ facet (§7.3.3, §7.6.3) */
.library-search-shell .lsv2-cats { margin: 16px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--mz-rule); min-width: 0; }
.library-search-shell .lsv2-cats legend { padding: 0; margin-bottom: 8px; color: var(--lsv2-strong); font: 700 12px/16px var(--mz-condensed); letter-spacing: 0.08em; text-transform: uppercase; }
.library-search-shell .lsv2-check { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.library-search-shell .lsv2-check input { position: absolute; opacity: 0; width: 18px; height: 18px; margin: 0; }
.library-search-shell .lsv2-check__box { position: relative; width: 18px; height: 18px; border: 1.5px solid var(--lsv2-control); background: transparent; }
.library-search-shell .lsv2-check input:checked + .lsv2-check__box { border-color: var(--mz-red-fill, var(--mz-red)); background: var(--mz-red-fill, var(--mz-red)); }
.library-search-shell .lsv2-check input:checked + .lsv2-check__box::after { content: ""; position: absolute; left: 4.5px; top: 0.5px; width: 5px; height: 10px; border: solid var(--mz-on-red); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.library-search-shell .lsv2-check input:focus-visible + .lsv2-check__box { outline: 2px solid var(--mz-focus, var(--mz-red)); outline-offset: 3px; }
.library-search-shell .lsv2-check__label { min-width: 0; color: var(--mz-ink); font: 400 14.5px/20px var(--mz-serif); }
.library-search-shell .lsv2-check__count { color: var(--mz-muted); font: 400 13px/18px var(--mz-condensed); }

@media (max-width: 760px) {
  .library-search-shell .lsv2-group__head { grid-template-columns: 56px minmax(0, 1fr); gap: 14px; }
  .library-search-shell .lsv2-cover { width: 56px; }
  .library-search-shell .lsv2-title { font-size: 16px; line-height: 21px; }
  .library-search-shell .lsv2-hits,
  .library-search-shell .lsv2-foot,
  .library-search-shell .lsv2-group .lsv2-inline-error { margin-left: 0; }
  .library-search-shell .lsv2-act--related { display: none; }
  .library-search-shell .lsv2-skeleton { grid-template-columns: 56px minmax(0, 1fr); gap: 14px; }
  .library-search-shell .lsv2-state__actions { gap: 12px 20px; }
}
.library-search-shell .lsv2-gated-count { margin: 24px 0 0; }
.library-search-shell .lsv2-gated-count + .lsv2-gated-note { margin-top: 12px; }
html body .library-search-shell .library-search-summary.library-search-summary { color: var(--mz-muted); font: 700 13px/18px var(--mz-condensed); letter-spacing: 0.08em; text-transform: uppercase; }
html body .library-search-shell .library-search-summary.library-search-summary b { color: var(--lsv2-strong); }
