:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #162033;
  --muted: #4f5f79;
  --border: #d6deef;
  --accent: #1c4fd1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

.opac-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem 0;
}

.page-shell {
  width: min(1700px, calc(100% - 2rem));
  margin-inline: auto;
}

.opac-header-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.homepage-sections {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0.2rem 0 0.35rem;
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
}

.subhead {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.header-search {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 0.45rem;
  width: min(100%, 460px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.feature-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.edge-anchor {
  width: 100%;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

h2 {
  margin: 0 0 0.65rem;
  font-size: 1.1rem;
}

.horizontal-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - (5 * 0.75rem)) / 6);
  gap: 0.75rem;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.scroller-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.scroll-btn {
  width: auto;
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.mini-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  min-width: 0;
  display: grid;
}

.mini-title {
  margin: 0;
  font-weight: 700;
}

.mini-meta {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.shelf-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  background: #f8faff;
  cursor: pointer;
}

.shelf-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
}

.shelf-item {
  margin: 0.3rem 0;
  color: var(--muted);
}

.shelf-count {
  margin: 0.65rem 0 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.format-pill,
.ghost-link {
  width: auto;
  border-radius: 999px;
}

.ghost-link {
  background: #edf2ff;
  border: 1px solid #c8d7ff;
}

.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
}

label span {
  display: block;
  font-size: 0.83rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--surface);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
}

#summary {
  margin: 0;
  color: var(--muted);
}

#refreshBtn {
  width: auto;
  border-radius: 999px;
  border-color: #bfcdf0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(19, 28, 48, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 30;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid #b7c5e9;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.modal-header h2 {
  margin: 0;
}

.icon-btn {
  width: auto;
  border-radius: 999px;
  padding-inline: 0.75rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem;
}

.clickable-card {
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.clickable-card:hover,
.clickable-card:focus-visible {
  transform: translateY(-2px);
  border-color: #a9beef;
  box-shadow: 0 8px 18px rgba(24, 52, 121, 0.12);
  outline: none;
}

.card-cover {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border);
}

.card-title { margin: 0; font-size: 1.05rem; }
.card-meta { margin: 0.35rem 0 0.5rem; color: var(--muted); }
.card-line { margin: 0.2rem 0; font-size: 0.94rem; }
.empty { margin: 0.4rem 0; color: var(--muted); }

.mini-cover {
  width: 100%;
  max-width: 180px;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 0.45rem;
  border: 1px solid var(--border);
}

.record-modal-card {
  width: min(860px, 100%);
}

.record-profile {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.detail-meta,
.detail-line {
  margin: 0.35rem 0;
  color: var(--muted);
}

.record-core-facts {
  margin: 0.75rem 0 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
}

.fact-panel {
  border: 1px solid #c7d5f3;
  border-radius: 10px;
  background: #f7faff;
  padding: 0.55rem 0.65rem;
}

.fact-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: #3d5ca6;
  font-weight: 700;
}

.fact-value {
  margin: 0.3rem 0 0;
  color: var(--ink);
  font-weight: 700;
}

.fact-value.callout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: #eef3ff;
  border: 1px solid #ccdaf8;
  border-radius: 8px;
  padding: 0.25rem 0.45rem;
  display: inline-block;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  border: 1px solid transparent;
}

.status-pill-available {
  background: #e9faee;
  color: #0f6a37;
  border-color: #b9e6c8;
}

.status-pill-unavailable {
  background: #fff2e8;
  color: #985319;
  border-color: #f0d1b4;
}

.detail-tip {
  background: #f5f8ff;
  border: 1px solid #d8e2fa;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.record-actions button,
.detail-chip {
  width: auto;
  border-radius: 999px;
}

.detail-notice {
  min-height: 1.3rem;
  margin: 0.65rem 0 0;
  color: var(--accent);
}

.detail-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

@media (max-width: 1100px) {
  .horizontal-scroller {
    grid-auto-columns: calc((100% - (2 * 0.75rem)) / 3);
  }
}

@media (max-width: 700px) {
  .modal {
    padding: 0.5rem;
  }

  .modal-card {
    max-height: calc(100vh - 1rem);
  }

  .opac-header-inner {
    flex-direction: column;
  }

  .header-search {
    grid-template-columns: 1fr;
  }

  .summary-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .record-profile {
    grid-template-columns: 1fr;
  }

  .detail-cover {
    max-width: 180px;
  }

  .horizontal-scroller {
    grid-auto-columns: calc((100% - 0.75rem) / 2);
  }
}

@media (max-width: 520px) {
  .results-grid {
    grid-template-columns: 1fr;
  }

  .search-panel {
    grid-template-columns: 1fr;
  }

  .scroller-controls {
    width: 100%;
    justify-content: flex-start;
  }
}