/* ══════════════════════════════════════════════════════════════════════
   NSPRI e-Library — design system
   Brand family: Fraunces (display) + Inter (body)
   Palette: ink black · harvest gold · brick red · warm paper
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --ink:        #1c1a12;
  --ink-soft:   #4a4536;
  --paper:      #fbf8f0;
  --paper-deep: #f3edde;
  --gold:       #e2a400;
  --gold-deep:  #b98600;
  --red:        #b3392b;
  --line:       #e3dcc8;
  --white:      #ffffff;

  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Inter", -apple-system, "Segoe UI", sans-serif;

  --radius: 10px;
  --shadow: 0 2px 14px rgba(28, 26, 18, 0.08);
  --shadow-lift: 0 10px 30px rgba(28, 26, 18, 0.14);
  --container: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  font-size: 16px;
}

img { max-width: 100%; display: block; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 26px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--gold); color: var(--ink); }
.btn-primary:hover { background: var(--gold-deep); color: var(--white); }
.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-sm { padding: 8px 18px; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar { background: var(--ink); color: var(--paper); font-size: 0.85rem; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; padding-top: 7px; padding-bottom: 7px; flex-wrap: wrap; gap: 6px; }
.topbar a { color: var(--gold); }
.topbar .sep { margin: 0 8px; opacity: 0.5; }
.topbar-user { margin-right: 10px; opacity: 0.85; }
.inline-form { display: inline; }
.linklike { background: none; border: none; color: var(--gold); font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { text-decoration: underline; }

/* ── Header / nav ────────────────────────────────────────────────── */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; gap: 20px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none !important; }
.brand-logo { width: 46px; height: 46px; border-radius: 50%; }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--ink); }
.brand-text em { font-style: italic; color: var(--red); }

.main-nav { display: flex; gap: 28px; }
.main-nav a {
  color: var(--ink); font-weight: 500; font-size: 0.95rem;
  padding: 6px 0; border-bottom: 3px solid transparent;
  text-decoration: none !important;
}
.main-nav a:hover { border-bottom-color: var(--gold); }
.main-nav a.active { border-bottom-color: var(--red); font-weight: 600; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 24px; height: 2.5px; background: var(--ink); margin: 5px 0; transition: transform 0.2s, opacity 0.2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ── Messages ────────────────────────────────────────────────────── */
.messages { margin: 16px 0 0; }
.msg { padding: 12px 18px; border-radius: var(--radius); margin-bottom: 8px; font-size: 0.95rem; border-left: 4px solid; }
.msg-success { background: #eef6e9; border-color: #4c8a3f; color: #2c5424; }
.msg-info    { background: #eef2f6; border-color: #3f6c8a; color: #24445c; }
.msg-error   { background: #f9ebe8; border-color: var(--red); color: #7a271d; }

/* ── Hero ────────────────────────────────────────────────────────── */
.hero {
  background:
    radial-gradient(1100px 420px at 85% -60%, rgba(226,164,0,0.28), transparent 65%),
    var(--ink);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}
.hero::after {                              /* thin gold shelf line */
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--gold), var(--red));
}
.hero-inner { padding: 72px 20px 64px; }
.hero-rotator { position: relative; min-height: 240px; }
.hero-slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity 0.6s ease;
  max-width: 820px;
}
.hero-slide.is-active { position: relative; opacity: 1; visibility: visible; }
.hero-eyebrow {
  font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 14px;
}
.hero-heading {
  font-size: clamp(1.9rem, 4.4vw, 3.4rem);
  font-weight: 900; color: var(--paper);
  text-wrap: balance;
}
.hero-subtext { margin-top: 16px; font-size: 1.05rem; color: rgba(251,248,240,0.82); max-width: 620px; }
.hero-dots { display: flex; gap: 10px; margin-top: 30px; }
.hero-dot {
  width: 30px; height: 5px; border-radius: 3px; border: none; cursor: pointer;
  background: rgba(251,248,240,0.3); transition: background 0.2s;
}
.hero-dot.is-active { background: var(--gold); }

/* ── Search card ─────────────────────────────────────────────────── */
.search-panel { margin-top: -34px; position: relative; z-index: 5; }
.search-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 26px 28px;
}
.search-card-slim { margin-bottom: 28px; box-shadow: var(--shadow); }
.search-card-head h2 { font-size: 1.25rem; margin-bottom: 16px; }
.search-card-fields { display: grid; grid-template-columns: 2.2fr 1fr 1fr auto; gap: 12px; }
.search-card-fields input[type="text"],
.search-card-fields select {
  padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--paper); color: var(--ink); width: 100%;
}
.search-card-fields input:focus, .search-card-fields select:focus { border-color: var(--gold); }

/* ── Sections ────────────────────────────────────────────────────── */
.section { padding: 64px 0; }
.section-alt { background: var(--paper-deep); }
.section-head { max-width: 640px; margin-bottom: 36px; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 8px; }
.section-head p { color: var(--ink-soft); }
.section-more { text-align: center; margin-top: 36px; }
.empty-note { color: var(--ink-soft); }

/* ── Format cards ────────────────────────────────────────────────── */
.format-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.format-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 22px; text-decoration: none !important;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  border-top: 4px solid var(--gold);
}
.format-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-top-color: var(--red); }
.format-icon { font-size: 1.8rem; }
.format-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.format-tagline { font-size: 0.85rem; color: var(--ink-soft); }
.format-cta { margin-top: auto; padding-top: 10px; font-size: 0.85rem; font-weight: 600; color: var(--red); }

/* ── Resource cards (index-card motif) ───────────────────────────── */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; }
.resource-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.resource-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.resource-cover {
  position: relative; display: block; aspect-ratio: 3 / 2;
  background: repeating-linear-gradient(0deg, var(--paper-deep), var(--paper-deep) 26px, var(--line) 27px); /* ruled card lines */
}
.resource-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback {
  width: 100%; height: 100%; display: grid; place-items: center; font-size: 2.4rem;
}
.cover-fallback-lg { font-size: 4.5rem; min-height: 320px; }
.badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
}
.badge-new { background: var(--red); color: var(--white); }
.resource-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 4px; }
.resource-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-deep); }
.resource-title { font-size: 1.02rem; font-weight: 600; }
.resource-title a { color: var(--ink); }
.resource-author { font-size: 0.88rem; color: var(--ink-soft); font-style: italic; }

/* ── List view rows ──────────────────────────────────────────────── */
.resource-list { display: flex; flex-direction: column; gap: 14px; }
.resource-row {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 18px; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px;
}
.row-cover { width: 110px; height: 78px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(0deg, var(--paper-deep), var(--paper-deep) 16px, var(--line) 17px); }
.row-cover img { width: 100%; height: 100%; object-fit: cover; }
.row-cover .cover-fallback { font-size: 1.6rem; }
.row-desc { font-size: 0.9rem; color: var(--ink-soft); margin-top: 4px; }

/* ── Listing toolbar ─────────────────────────────────────────────── */
.listing-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.listing-count { font-size: 0.92rem; color: var(--ink-soft); }
.view-toggle { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.view-btn { padding: 7px 18px; font-size: 0.85rem; font-weight: 600; color: var(--ink); text-decoration: none !important; }
.view-btn.is-active { background: var(--ink); color: var(--paper); }

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 22px; margin-top: 40px; font-weight: 600; }
.pagination a { color: var(--red); }
.page-current { color: var(--ink-soft); font-weight: 400; font-size: 0.92rem; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 2.6rem; margin-bottom: 10px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--ink-soft); }

/* ── Page head ───────────────────────────────────────────────────── */
.page-head {
  background:
    radial-gradient(900px 300px at 90% -80%, rgba(226,164,0,0.22), transparent 65%),
    var(--ink);
  color: var(--paper);
  padding: 44px 0 40px;
  border-bottom: 5px solid var(--gold);
}
.page-head h1 { color: var(--paper); font-size: clamp(1.7rem, 3.6vw, 2.6rem); }
.page-sub { color: rgba(251,248,240,0.8); margin-top: 8px; }
.breadcrumb { font-size: 0.82rem; letter-spacing: 0.04em; margin-bottom: 12px; color: rgba(251,248,240,0.65); }
.breadcrumb a { color: var(--gold); }

/* ── Welcome ─────────────────────────────────────────────────────── */
.welcome-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 48px; align-items: start; }
.welcome-text h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: 16px; }
.welcome-text p { margin-bottom: 14px; color: var(--ink-soft); }
.welcome-facts { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 90px; }
.fact-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--gold);
  border-radius: var(--radius); padding: 16px 20px;
}
.fact-name { font-family: var(--font-display); font-weight: 700; }
.fact-card a { font-size: 0.85rem; font-weight: 600; }

/* ── Events ──────────────────────────────────────────────────────── */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.event-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.event-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.event-media { display: block; aspect-ratio: 16 / 9; background: var(--paper-deep); }
.event-media img { width: 100%; height: 100%; object-fit: cover; }
.event-media-fallback { width: 100%; height: 100%; display: grid; place-items: center; font-size: 2.2rem; }
.event-body { padding: 18px 20px 20px; }
.event-date { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); }
.event-title { font-size: 1.1rem; margin: 6px 0 8px; }
.event-title a { color: var(--ink); }
.event-summary { font-size: 0.92rem; color: var(--ink-soft); }
.event-location { font-size: 0.82rem; color: var(--gold-deep); margin-top: 8px; font-weight: 600; }

/* ── Article (event detail) ──────────────────────────────────────── */
.article-narrow { max-width: 760px; }
.article-image { border-radius: var(--radius); margin-bottom: 26px; }
.article-lede { font-size: 1.15rem; font-weight: 500; margin-bottom: 20px; }
.article-body p { margin-bottom: 14px; color: var(--ink-soft); }

/* ── Services ────────────────────────────────────────────────────── */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.service-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 26px; border-top: 4px solid var(--gold);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.service-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.service-icon { font-size: 1.9rem; display: block; margin-bottom: 12px; }
.service-card h3 { font-size: 1.15rem; margin-bottom: 8px; }
.service-card p { font-size: 0.94rem; color: var(--ink-soft); }

/* ── Detail page ─────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 48px; align-items: start; }
.detail-cover { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper-deep); }
.detail-title { font-size: clamp(1.5rem, 3vw, 2.2rem); margin: 6px 0 4px; }
.detail-author { font-style: italic; color: var(--ink-soft); margin-bottom: 20px; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.detail-meta div { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.detail-meta dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-deep); }
.detail-meta dd { font-weight: 600; }
.detail-desc { color: var(--ink-soft); margin-bottom: 24px; }
.detail-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.access-note { font-size: 0.88rem; color: var(--ink-soft); }

/* ── Newsletter ──────────────────────────────────────────────────── */
.newsletter { background: var(--gold); padding: 48px 0; }
.newsletter-inner { display: flex; justify-content: space-between; align-items: center; gap: 30px; flex-wrap: wrap; }
.newsletter h2 { font-size: 1.5rem; }
.newsletter p { color: rgba(28,26,18,0.75); }
.newsletter-form { display: flex; gap: 10px; flex: 1; max-width: 460px; }
.newsletter-form input[type="email"] {
  flex: 1; padding: 12px 18px; border: 2px solid var(--ink); border-radius: 999px;
  font: inherit; background: var(--paper);
}

/* ── Contact ─────────────────────────────────────────────────────── */
.contact-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 48px; align-items: start; }
.info-block { margin-bottom: 26px; }
.info-block h3 { font-size: 1.05rem; margin-bottom: 8px; border-left: 4px solid var(--gold); padding-left: 10px; }
.contact-form-wrap h2 { margin-bottom: 20px; }
.contact-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.form-field .optional { font-weight: 400; color: var(--ink-soft); }
.form-field input, .form-field textarea {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--white);
}
.form-field input:focus, .form-field textarea:focus { border-color: var(--gold); }
.form-field .errorlist { list-style: none; color: var(--red); font-size: 0.82rem; margin-top: 4px; }
.map-section { line-height: 0; }
.map-section iframe { filter: saturate(0.85); }

/* ── Auth ────────────────────────────────────────────────────────── */
.auth-section { display: flex; }
.auth-card {
  max-width: 420px; margin: 20px auto;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  border-top: 5px solid var(--gold);
  padding: 38px 36px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-sub { color: var(--ink-soft); margin-bottom: 22px; font-size: 0.95rem; }
.auth-note { margin-top: 18px; font-size: 0.88rem; color: var(--ink-soft); }

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer { background: var(--ink); color: rgba(251,248,240,0.8); margin-top: 40px; }
.footer-grid {
  display: grid; grid-template-columns: 1.4fr 1.1fr 0.9fr 0.8fr;
  gap: 40px; padding: 54px 20px 40px; font-size: 0.92rem;
}
.footer-heading { color: var(--gold); font-size: 1rem; margin-bottom: 12px; }
.footer-heading + .footer-heading, p + .footer-heading { margin-top: 18px; }
.footer-list { list-style: none; }
.footer-list li { margin-bottom: 4px; }
.footer-links a, .footer-contact a, .site-footer p a { color: rgba(251,248,240,0.85); }
.footer-links a:hover { color: var(--gold); }
.footer-contact { margin-top: 12px; }
.footer-bottom { border-top: 1px solid rgba(251,248,240,0.12); padding: 16px 0; font-size: 0.82rem; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .search-card-fields { grid-template-columns: 1fr 1fr; }
  .search-card-fields input[type="text"] { grid-column: 1 / -1; }
  .search-card-fields .btn { grid-column: 1 / -1; }
  .welcome-grid, .contact-grid, .detail-grid { grid-template-columns: 1fr; }
  .welcome-facts { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .detail-cover { max-width: 340px; }
}

@media (max-width: 720px) {
  .main-nav {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    flex-direction: column; gap: 0; padding: 10px 20px 16px;
    box-shadow: var(--shadow-lift);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .main-nav a.active { border-bottom-color: var(--red); }
  .nav-toggle { display: block; }
  .hero-inner { padding: 52px 20px 48px; }
  .hero-rotator { min-height: 300px; }
  .resource-row { grid-template-columns: 84px 1fr; }
  .row-actions { grid-column: 2; }
  .row-cover { width: 84px; height: 60px; }
  .contact-form .form-row { grid-template-columns: 1fr; }
  .newsletter-form { width: 100%; max-width: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
}

/* ══════════════════════════════════════════════════════════════════════
   Live chat — floating widget + librarian desk
   ══════════════════════════════════════════════════════════════════════ */

.unread-pill {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--red); color: var(--white);
  font-size: 0.72rem; font-weight: 700; line-height: 1;
}

/* ── Floating widget ─────────────────────────────────────────────── */
.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 90; }
.chat-launcher {
  display: flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--gold); border-radius: 999px;
  padding: 12px 20px; font: inherit; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; box-shadow: var(--shadow-lift);
  transition: transform 0.15s ease;
}
.chat-launcher:hover { transform: translateY(-2px); }
.chat-launcher-icon { font-size: 1.1rem; }

.chat-panel {
  position: absolute; right: 0; bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 40px));
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lift);
  overflow: hidden; display: flex; flex-direction: column;
}
.chat-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  background: var(--ink); color: var(--paper); padding: 14px 16px;
  border-bottom: 3px solid var(--gold);
}
.chat-status { display: block; font-size: 0.75rem; opacity: 0.75; margin-top: 2px; }
.chat-close {
  background: none; border: none; color: var(--paper);
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px;
}

.chat-body {
  height: 320px; overflow-y: auto; padding: 16px;
  background: var(--paper);
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty p { font-size: 0.9rem; color: var(--ink-soft); text-align: center; padding: 20px 8px; }
.chat-guest { height: auto; padding: 22px 20px; text-align: center; display: block; }
.chat-guest p { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 14px; }
.chat-guest-note { margin-top: 14px; font-size: 0.85rem !important; }

.chat-msg { max-width: 82%; display: flex; flex-direction: column; }
.chat-msg-mine { align-self: flex-end; align-items: flex-end; }
.chat-msg-theirs { align-self: flex-start; align-items: flex-start; }
.chat-msg-sender { font-size: 0.7rem; font-weight: 700; color: var(--gold-deep); margin-bottom: 2px; letter-spacing: 0.04em; }
.chat-msg-text {
  padding: 9px 14px; border-radius: 14px; font-size: 0.92rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg-mine .chat-msg-text { background: var(--gold); color: var(--ink); border-bottom-right-radius: 4px; }
.chat-msg-theirs .chat-msg-text { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg-time { font-size: 0.68rem; color: var(--ink-soft); margin-top: 3px; }

.chat-input {
  display: flex; gap: 8px; padding: 12px; background: var(--white);
  border-top: 1px solid var(--line);
}
.chat-input input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--line);
  border-radius: 999px; font: inherit; background: var(--paper);
}
.chat-input input:focus { border-color: var(--gold); }

/* ── Librarian desk ──────────────────────────────────────────────── */
.chat-thread-list { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.chat-thread-row {
  display: grid; grid-template-columns: 200px 1fr auto; gap: 16px; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; text-decoration: none !important; color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.chat-thread-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.chat-thread-row.has-unread { border-left: 5px solid var(--red); }
.thread-who strong { display: block; }
.thread-username { font-size: 0.8rem; color: var(--ink-soft); }
.thread-preview { font-size: 0.9rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-preview .you { font-weight: 700; color: var(--gold-deep); }
.thread-meta { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--ink-soft); }

.chat-desk {
  max-width: 760px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.chat-body-desk { height: 440px; }

@media (max-width: 720px) {
  .chat-launcher-label { display: none; }
  .chat-launcher { padding: 14px; }
  .chat-thread-row { grid-template-columns: 1fr; gap: 6px; }
}

.auth-card-wide { max-width: 620px; }
.auth-card-wide .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.auth-card input[type="text"], .auth-card input[type="password"], .auth-card input[type="email"] {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--white);
}
.auth-card input:focus { border-color: var(--gold); }
.auth-card .errorlist { list-style: none; color: var(--red); font-size: 0.82rem; margin-top: 4px; }
.auth-card .helptext { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }
@media (max-width: 560px) { .auth-card-wide .form-row { grid-template-columns: 1fr; } }

/* ── Card description + quick actions ────────────────────────────── */
.resource-desc {
  font-size: 0.85rem; color: var(--ink-soft); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.resource-card-actions {
  margin-top: auto; padding-top: 10px;
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 600;
}
.card-link { color: var(--red); }
.card-link-sep { color: var(--line); }
.resource-body { flex: 1; }
.row-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

/* ── Online reader ───────────────────────────────────────────────── */
.reader-head-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.reader-actions { display: flex; gap: 10px; padding-bottom: 4px; }
.reader-btn-light { color: var(--paper); border-color: rgba(251,248,240,0.5); }
.reader-btn-light:hover { background: var(--paper); color: var(--ink); }

.reader-stage { background: #26241b; padding: 28px 0; }
.reader-frame {
  display: block; width: 100%; height: min(80vh, 900px);
  border: none; border-radius: var(--radius); background: var(--white);
  box-shadow: var(--shadow-lift);
}
.reader-fallback { text-align: center; margin-top: 12px; font-size: 0.85rem; color: rgba(251,248,240,0.7); }
.reader-fallback a { color: var(--gold); }

.reader-media-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.reader-media-wrap img { max-height: 78vh; border-radius: var(--radius); box-shadow: var(--shadow-lift); }
.reader-media-wrap video { width: 100%; max-height: 78vh; border-radius: var(--radius); background: #000; }
.reader-audio { padding: 40px 0; }
.reader-audio-cover { max-width: 280px; }
.reader-media-wrap audio { width: min(560px, 100%); }
.reader-about { margin-bottom: 12px; }

@media (max-width: 720px) {
  .reader-frame { height: 72vh; }
  .row-actions { flex-direction: row; }
}

/* ══════════════════════════════════════════════════════════════════════
   Engagement: ratings, bookmarks, comments, My Library, requests
   ══════════════════════════════════════════════════════════════════════ */

.count-pill {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px;
  padding: 0 8px; margin-left: 6px; vertical-align: middle;
  border-radius: 999px; background: var(--gold); color: var(--ink);
  font-family: var(--font-body); font-size: 0.85rem; font-weight: 700;
}

/* ── Stars ───────────────────────────────────────────────────────── */
.rating-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.stars-display .star { color: var(--line); font-size: 1.2rem; }
.stars-display .star-on { color: var(--gold); }
.rating-text { font-size: 0.9rem; color: var(--ink-soft); }

.rate-box {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 26px; margin-bottom: 34px; border-left: 5px solid var(--gold);
}
.rate-box h2 { font-size: 1.2rem; margin-bottom: 12px; }
.star-form { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.star-input { display: inline-flex; flex-direction: row-reverse; }
.star-input input { position: absolute; opacity: 0; pointer-events: none; }
.star-input label { font-size: 1.9rem; color: var(--line); cursor: pointer; padding: 0 3px; transition: color 0.1s; }
.star-input label:hover,
.star-input label:hover ~ label,
.star-input input:checked ~ label { color: var(--gold); }

/* ── Bookmark button ─────────────────────────────────────────────── */
.bookmark-btn.is-saved { background: var(--red); border-color: var(--red); color: var(--white); }
.bookmark-btn.is-saved:hover { background: #922d21; }

/* ── Comments ────────────────────────────────────────────────────── */
.comments h2 { font-size: 1.35rem; margin-bottom: 16px; }
.comment-count { color: var(--ink-soft); font-family: var(--font-body); font-size: 1rem; font-weight: 400; }
.comment-form { margin-bottom: 26px; }
.comment-form textarea {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--white); margin-bottom: 10px; resize: vertical;
}
.comment-form textarea:focus { border-color: var(--gold); }
.comment-login-note { margin-bottom: 24px; color: var(--ink-soft); }
.comment-empty { color: var(--ink-soft); }

.comment {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px;
}
.comment-reply { margin: 12px 0 0 34px; background: var(--paper); }
.comment-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.comment-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--gold);
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
}
.comment-time { display: block; font-size: 0.75rem; color: var(--ink-soft); }
.comment-text { font-size: 0.95rem; margin-bottom: 10px; }
.comment-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.react-btn {
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: 0.95rem; cursor: pointer; line-height: 1.3;
  transition: transform 0.1s, border-color 0.1s;
}
.react-btn:hover { transform: scale(1.12); border-color: var(--gold); }
.react-btn.is-mine { background: var(--gold); border-color: var(--gold-deep); }
.react-count {
  font-size: 0.8rem; color: var(--ink-soft);
  background: var(--paper-deep); border-radius: 999px; padding: 3px 9px;
}
.comment-reply-toggle, .comment-delete { font-size: 0.83rem; color: var(--red); font-weight: 600; }
.reply-form { margin: 12px 0 0 34px; }

/* ── My Library ──────────────────────────────────────────────────── */
.saved-wrap { position: relative; display: flex; flex-direction: column; }
.saved-remove { margin-top: 6px; text-align: right; }
.saved-remove .linklike { font-size: 0.8rem; color: var(--ink-soft); }
.saved-remove .linklike:hover { color: var(--red); }

.history-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.history-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; text-decoration: none !important; color: var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.history-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.history-icon { font-size: 1.3rem; }
.history-title { font-weight: 600; }
.history-meta { font-size: 0.8rem; color: var(--ink-soft); white-space: nowrap; }

/* ── Book requests ───────────────────────────────────────────────── */
.request-list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; margin-top: 18px; }
.request-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px;
}
.request-author { color: var(--ink-soft); }
.request-note { font-size: 0.85rem; color: var(--gold-deep); margin-top: 4px; }
.request-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 0.8rem; color: var(--ink-soft); }
.status-pill {
  padding: 4px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
}
.status-pending  { background: var(--paper-deep); color: var(--ink-soft); }
.status-approved { background: #eef2f6; color: #24445c; }
.status-acquired { background: #eef6e9; color: #2c5424; }
.status-declined { background: #f9ebe8; color: #7a271d; }

@media (max-width: 720px) {
  .history-row { grid-template-columns: auto 1fr; }
  .history-meta { grid-column: 2; white-space: normal; }
  .request-row { flex-direction: column; }
  .request-meta { flex-direction: row; align-items: center; }
  .comment-reply, .reply-form { margin-left: 14px; }
}
