:root {
  --ink: #2b2118;
  --ink-soft: #4a3a2b;
  --muted: #766655;

  --wood-dark: #3a2417;
  --wood: #5a3520;
  --wood-mid: #744a2c;
  --wood-light: #96643d;

  --paper: #f8f2e7;
  --paper-soft: #efe4d2;
  --paper-deep: #e3d2ba;

  --line: #c9b79e;
  --bg: #d8c5aa;
  --card: #fbf7ef;

  --accent: #31513d;
  --accent-dark: #21392b;
  --accent-light: #dfe8df;

  --brass: #b68a46;
  --brass-dark: #8f692f;
  --brass-light: #ead7aa;

  --ok: #315f43;
  --ok-bg: #dce9de;

  --res: #3f587a;
  --res-bg: #dfe6ef;

  --no: #8a3f35;
  --no-bg: #f1dddd;

  --radius: 6px;

  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.16) 25%,
      transparent 25%
    ),
    linear-gradient(
      315deg,
      rgba(87,55,32,.08) 25%,
      transparent 25%
    ),
    var(--bg);
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  line-height: 1.2;
  margin: 0;
  color: var(--wood-dark);
}

p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 24px;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.04),
      transparent 40%,
      rgba(255,255,255,.03)
    ),
    var(--wood-dark);
  color: #f8f1e5;
  border-bottom: 3px solid var(--brass);
  box-shadow:
    0 3px 0 rgba(42,27,17,.28),
    0 8px 18px rgba(42,27,17,.18);
}

.brand {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: .01em;
}

.nav-links {
  display: flex;
  gap: 5px;
}

.nav-links a {
  padding: 8px 12px;
  border-radius: 4px;
  text-decoration: none;
  color: #d7c7b4;
  border: 1px solid transparent;
  transition:
    background .18s ease,
    color .18s ease,
    border-color .18s ease;
}

.nav-links a:hover {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.08);
}

.nav-links a.active {
  background: var(--paper);
  color: var(--wood-dark);
  border-color: var(--brass);
  font-weight: 700;
}

.nav-badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 10px;
  background: var(--brass);
  color: #2b2118;
  font-size: .75rem;
  font-weight: 800;
  text-align: center;
}

/* Layout */

.hero,
.section {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}

.section {
  padding-top: 32px;
  scroll-margin-top: 90px;
}

.section > h2 {
  font-size: 1.7rem;
  margin-bottom: 16px;
  position: relative;
  padding-bottom: 10px;
}

.section > h2::after {
  content: "";
  display: block;
  width: 54px;
  height: 3px;
  margin-top: 9px;
  background: var(--brass);
  border-radius: 3px;
}

.sub-h {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Hero */

.hero {
  position: relative;
  padding-top: 58px;
  padding-bottom: 38px;
}

.hero::before {
  content: "";
  position: absolute;
  top: 24px;
  left: 24px;
  width: 78px;
  height: 5px;
  border-radius: 3px;
  background: var(--brass);
  box-shadow: 0 1px 0 rgba(255,255,255,.5);
}

.hero h1 {
  font-size: 2.5rem;
  max-width: 18ch;
  letter-spacing: -.02em;
}

.hero p {
  margin-top: 10px;
  max-width: 670px;
  color: var(--ink-soft);
}

.hero-search {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin-top: 22px;
}

.hero-search input,
.search-row input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #bda88c;
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  box-shadow:
    inset 0 1px 2px rgba(72,48,28,.08),
    0 1px 0 rgba(255,255,255,.7);
}

.hero-search input::placeholder,
.search-row input::placeholder {
  color: #917f6b;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 32px;
}

.stat {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(
      145deg,
      rgba(255,255,255,.28),
      transparent 48%
    ),
    var(--paper);
  border: 1px solid var(--line);
  border-top: 4px solid var(--wood-mid);
  border-radius: var(--radius);
  padding: 17px 16px 16px;
  box-shadow:
    0 3px 8px rgba(70,43,23,.10),
    inset 0 1px 0 rgba(255,255,255,.65);
}

.stat::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -25px;
  width: 75px;
  height: 75px;
  border: 1px solid rgba(116,74,44,.10);
  border-radius: 50%;
}

.stat-label {
  font-size: .85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.stat-value {
  font-family: var(--serif);
  font-size: 2rem;
  margin: 2px 0;
  color: var(--wood-dark);
}

.stat-note {
  font-size: .85rem;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 8px;
  border-radius: 50%;
  background: #4f8358;
  box-shadow: 0 0 0 3px rgba(79,131,88,.12);
}

.status-dot.closed {
  background: #a64a40;
  box-shadow: 0 0 0 3px rgba(166,74,64,.12);
}

/* Buttons and chips */

.btn {
  padding: 10px 16px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
  transition:
    transform .12s ease,
    background .18s ease,
    border-color .18s ease,
    box-shadow .18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-primary {
  background:
    linear-gradient(
      180deg,
      #41634d,
      var(--accent)
    );
  color: #fff;
  border-color: var(--accent-dark);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.16),
    0 2px 4px rgba(33,57,43,.16);
}

.btn-primary:hover:not(:disabled) {
  background:
    linear-gradient(
      180deg,
      #355842,
      var(--accent-dark)
    );
}

.btn-outline {
  background: var(--paper);
  color: var(--wood-dark);
  border-color: var(--wood-mid);
}

.btn-outline:hover:not(:disabled) {
  background: var(--paper-soft);
  border-color: var(--accent);
}

.btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
}

.link-btn {
  background: none;
  border: 0;
  padding: 4px 8px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  margin-bottom: 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip-group button {
  padding: 6px 12px;
  border: 1px solid #c1ae95;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition:
    background .16s ease,
    border-color .16s ease,
    color .16s ease;
}

.chip-group button:hover {
  border-color: var(--wood-mid);
  background: var(--paper-soft);
}

.chip-group button.active {
  background: var(--wood-mid);
  border-color: var(--wood-dark);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.12);
}

.sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .9rem;
}

.sort-label select {
  padding: 6px 8px;
  border: 1px solid #c1ae95;
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
}

.result-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .9rem;
}

/* Badges */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 650;
  border: 1px solid transparent;
}

.badge.available {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #bdd3c2;
}

.badge.reserved {
  background: var(--res-bg);
  color: var(--res);
  border-color: #c3d0e2;
}

.badge.unavailable {
  background: var(--no-bg);
  color: var(--no);
  border-color: #e4bcbc;
}

.badge.category {
  background: var(--paper-deep);
  color: var(--wood-soft);
  border-color: #d2bea4;
}

/* Book cards */

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

.book-card {
  position: relative;
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  padding: 17px;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.46),
      transparent 52%
    ),
    var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--wood-mid);
  border-radius: var(--radius);
  box-shadow:
    0 3px 9px rgba(70,43,23,.08),
    inset 0 1px 0 rgba(255,255,255,.7);
}

.book-card::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 5px;
  height: 1px;
  background: rgba(116,74,44,.07);
}

.book-cover,
.detail-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.12),
      transparent 42%
    ),
    var(--wood-mid);
  color: #f7efe1;
  font-family: var(--serif);
  font-size: .8rem;
  text-align: center;
  border-radius: 4px;
  border: 2px solid var(--wood-dark);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,.06),
    2px 3px 6px rgba(54,32,19,.18);
}

.book-cover {
  width: 88px;
  height: 120px;
}

.book-info h3 {
  font-size: 1.15rem;
}

.book-author {
  color: var(--muted);
  margin: 2px 0 8px;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.book-location {
  font-size: .9rem;
  color: var(--ink-soft);
}

.book-location strong {
  color: var(--wood-dark);
}

.book-return {
  margin-top: 5px;
  font-size: .9rem;
  color: var(--no);
}

.book-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-width: 150px;
}

/* Empty state */

.empty-state {
  padding: 34px 16px;
  text-align: center;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.4),
      transparent 55%
    ),
    var(--card);
  border: 1px dashed #c4b197;
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.65);
}

.empty-state .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 9px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--wood-mid);
  border: 1px solid #ccb99d;
  font-weight: 750;
  font-size: .8rem;
}

.empty-state h3 {
  font-size: 1.05rem;
}

.empty-state p {
  color: var(--muted);
  margin-top: 4px;
}

/* Reservations and activity */

.res-item,
.activity-item,
.announcement {
  position: relative;
  padding: 15px 17px;
  margin-bottom: 10px;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.38),
      transparent 55%
    ),
    var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--wood-mid);
  border-radius: var(--radius);
  box-shadow:
    0 2px 6px rgba(70,43,23,.06);
}

.res-item h4 {
  font-size: 1rem;
}

.res-item p,
.res-meta,
.activity-meta,
.announcement-date {
  font-size: .85rem;
  color: var(--muted);
}

.res-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.activity-title,
.announcement-title {
  font-weight: 650;
  color: var(--wood-dark);
}

.announcement p {
  margin: 4px 0;
  color: var(--ink-soft);
}

/* Hours and popular */

.day-row,
.popular-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.25),
      transparent 55%
    ),
    var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 0;
}

.day-row:first-child,
.popular-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.day-row:last-child,
.popular-item:last-child {
  border-bottom-width: 1px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.day-row.today {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  font-weight: 650;
}

.closed-text {
  color: var(--no);
  font-weight: 650;
}

.popular-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
}

.popular-rank {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--brass-dark);
  font-weight: 700;
}

.popular-title {
  font-weight: 650;
  color: var(--wood-dark);
}

.popular-author,
.popular-count {
  font-size: .85rem;
  color: var(--muted);
}

/* Modals */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(42,27,17,.68);
  backdrop-filter: blur(3px);
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  background: var(--card);
  border: 1px solid #a98e70;
  border-radius: 7px;
  box-shadow:
    0 16px 40px rgba(39,24,15,.28),
    inset 0 1px 0 rgba(255,255,255,.7);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}

.modal-head {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(
      90deg,
      rgba(116,74,44,.08),
      transparent 55%
    );
}

.modal-head h2 {
  font-size: 1.25rem;
}

.modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: var(--paper-soft);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  background:
    linear-gradient(
      rgba(255,255,255,.25),
      rgba(255,255,255,.25)
    ),
    var(--card);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid #c4b197;
  border-radius: 50%;
  background: var(--paper-soft);
  color: var(--wood-dark);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--paper-deep);
  border-color: var(--wood-mid);
}

.detail-layout {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
}

.detail-cover {
  width: 110px;
  height: 150px;
}

.detail-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--wood-dark);
}

.detail-author {
  color: var(--muted);
}

.detail-description {
  margin-top: 12px;
  color: var(--ink-soft);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.detail-item {
  padding: 11px 12px;
  background: var(--paper-soft);
  border: 1px solid #d3c1a8;
  border-radius: var(--radius);
}

.detail-label {
  font-size: .8rem;
  color: var(--muted);
}

.detail-value {
  font-weight: 650;
  color: var(--wood-dark);
}

.detail-map-note {
  margin-top: 16px;
  padding: 13px;
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--ink-soft);
}

.shelf-map-top {
  padding: 9px;
  margin-bottom: 12px;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.04),
      transparent 50%
    ),
    var(--wood-dark);
  color: #f7efe1;
  text-align: center;
  font-size: .8rem;
  letter-spacing: .08em;
  border-radius: 4px;
  border: 1px solid #2d1c12;
}

.shelf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shelf-zone {
  padding: 13px;
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.3),
      transparent 55%
    ),
    var(--paper-soft);
  border: 2px solid #cfbda3;
  border-radius: var(--radius);
}

.shelf-zone.highlight {
  background:
    linear-gradient(
      135deg,
      rgba(255,255,255,.25),
      transparent 55%
    ),
    #ead9af;
  border-color: var(--brass);
  box-shadow:
    inset 0 0 0 1px rgba(182,138,70,.12),
    0 2px 6px rgba(91,64,31,.08);
}

.shelf-zone h4 {
  font-size: 1rem;
  color: var(--wood-dark);
}

.shelf-zone p {
  margin: 4px 0 8px;
  font-size: .85rem;
  color: var(--muted);
}

.shelf-range {
  font-size: .8rem;
  font-weight: 650;
  color: var(--wood-mid);
}

.shelf-location-note {
  margin-top: 14px;
  font-size: .95rem;
  color: var(--ink-soft);
}

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: 90vw;
  padding: 12px 18px;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.04),
      transparent 60%
    ),
    var(--wood-dark);
  color: #fff8eb;
  border: 1px solid var(--brass-dark);
  border-radius: 5px;
  box-shadow:
    0 7px 18px rgba(42,27,17,.22);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity .2s,
    transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Mobile nav */

.mobile-nav {
  display: none;
}

@media (max-width: 760px) {
  .nav-links {
    display: none;
  }

  .site-header {
    padding: 12px 16px;
  }

  body {
    padding-bottom: 64px;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background:
      linear-gradient(
        90deg,
        rgba(255,255,255,.03),
        transparent 55%
      ),
      var(--wood-dark);
    border-top: 2px solid var(--brass);
    box-shadow:
      0 -5px 16px rgba(42,27,17,.18);
  }

  .mobile-nav a {
    flex: 1;
    padding: 12px 4px;
    text-align: center;
    font-size: .8rem;
    text-decoration: none;
    color: #d9cbb8;
  }

  .mobile-nav a.active {
    color: #fff8eb;
    font-weight: 700;
    box-shadow: inset 0 3px 0 var(--brass);
  }

  .hero {
    padding-top: 44px;
  }

  .hero::before {
    top: 19px;
    left: 16px;
    width: 58px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .stats,
  .two-col,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .book-card {
    grid-template-columns: 72px 1fr;
  }

  .book-cover {
    width: 72px;
    height: 100px;
  }

  .book-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .book-actions .btn {
    flex: 1;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-cover {
    width: 100%;
    max-width: 150px;
    height: 180px;
  }

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

  .toast {
    bottom: 80px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .toast {
    transition: none;
  }

  .btn,
  .nav-links a,
  .chip-group button {
    transition: none;
  }
}