/*
 * UI/UX INTEGRATION ΓÇö 2026-10-28: EXACT stylesheet ported verbatim from
 * "ACTS Library System UI.html" (the finished design). Loaded by the rebuilt
 * user-facing views (guest catalog, login, student portal pages). The admin
 * portal keeps assets/css/acts-ui.css. Do not hand-edit the ported rules ΓÇö
 * regenerate from the design file if the design changes.
 */

:root {
  /* ===== ACTS Colleges root palette (assets/css/acts-theme.css) ΓÇö single source of truth ===== */
  --blue: #286DA8;
  /* primary ACTS blue */
  --blue-mid: #3F8CCC;
  --blue-lt: #75ACD8;
  --blue-dk: #235C90;
  /* deep blue ΓÇö headers, sidebar active, primary buttons */
  --gold: #D97A45;
  /* ACTS warm orange accent */
  --gold-dk: #B96538;
  --gold-ink: #99572F;
  --gold-soft: #F1C7AD;
  --white: #FFFFFF;
  --off: #F4F8FC;
  --cream: #FCF5EE;
  --text: #223548;
  --muted: #62778B;
  --border: #D4E0EA;
  /* ===== Everything below is derived from the root palette only ===== */
  --blue2: var(--blue-mid);
  --blue-dark: var(--blue-dk);
  --blue-soft: #DFEDF8;
  /* blue-lt tint ΓÇö chips, active nav, focus rings */
  --blue-pale: #C9DDEF;
  /* pale blue text on deep-blue panels */
  --orange: var(--gold);
  --orange-dark: var(--gold-ink);
  --orange-soft: #FBEFE6;
  /* gold tint on cream */
  --mist: var(--off);
  --bg: var(--off);
  --surface: var(--white);
  --surface2: #F7FAFC;
  --ink: var(--text);
  --ink2: #3D546C;
  --faint: #8FA6BA;
  --line: var(--border);
  --line2: #BFD3E4;
  --green: var(--blue-dk);
  /* Available / Returned / success = ACTS blue family */
  --green-soft: var(--blue-soft);
  --red: #A34A22;
  /* Overdue = deepened gold-dk red */
  --red-soft: #F8E7DA;
  /* gold-soft tint */
  --amber: var(--gold-ink);
  /* Borrowed / due-soon = gold family */
  --amber-soft: #FBEFE6;
  --shadow: 0 10px 30px rgba(35, 92, 144, .10);
  --shadow-sm: 0 2px 8px rgba(35, 92, 144, .07);
  --radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

/* The scrollbar gutter is reserved at ALL times (modal or not), so the
         layout width is one constant: opening a modal and hiding the page
         scrollbar changes nothing, and no compensation padding is ever
         needed. html also carries the page background so the gutter strip
         itself can never render as a white seam. */
html {
  background: var(--bg);
  scrollbar-gutter: stable;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.serif {
  font-family: "Playfair Display", Georgia, serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

a {
  color: var(--blue2);
  text-decoration: none;
}

::selection {
  background: var(--orange);
  color: #fff;
}

.hidden {
  display: none !important;
}

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  background: var(--blue-dk);
  color: #fff;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--blue);
}

.btn:active {
  transform: translateY(1px);
}

.btn.orange {
  background: var(--gold-dk);
}

.btn.orange:hover {
  background: var(--gold-ink);
}

.btn.ghost {
  background: var(--surface);
  color: var(--ink2);
  border-color: var(--line2);
}

.btn.ghost:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn.danger-ghost {
  background: var(--surface);
  color: var(--red);
  border-color: var(--line2);
}

.btn.danger-ghost:hover {
  border-color: var(--red);
  background: var(--red-soft);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.btn.danger:hover {
  filter: brightness(.92);
}

.btn.sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink2);
  position: relative;
  transition: border-color .15s, color .15s;
}

.icon-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line2);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue2);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.select-pop {
  position: fixed;
  z-index: 10050;
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line2);
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.select-pop button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}

.select-pop button:hover,
.select-pop button[aria-selected="true"] {
  background: var(--blue-dk);
  color: #fff;
}

.field .err-text {
  color: var(--red);
  font-size: 12.5px;
  margin-top: 5px;
  font-weight: 500;
}

.field input.invalid {
  border-color: var(--red);
}

.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--faint);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--line2);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
}

.search-box input:focus {
  border-color: var(--blue2);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

/* ---------- Login (reference portal design) ---------- */
#loginScreen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-dk) 0%, var(--blue) 100%);
  position: relative;
  overflow: hidden;
  padding: 36px 16px 28px;
}

#loginScreen::before {
  content: "";
  position: absolute;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  top: -220px;
  right: -140px;
  pointer-events: none;
}

#loginScreen::after {
  content: "";
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  bottom: -180px;
  left: -120px;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 392px;
  background: var(--surface);
  border: 1px solid var(--gold-soft);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(18, 36, 54, .32);
  overflow: hidden;
}

.login-card-head {
  background: linear-gradient(135deg, #1F4E79 0%, var(--blue-dk) 55%, var(--blue) 100%);
  padding: 20px 24px 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card-head::before {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  left: -52px;
  bottom: -72px;
  pointer-events: none;
}

.login-card-head::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  right: -36px;
  top: -58px;
  pointer-events: none;
}

.login-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  z-index: 1;
  text-align: left;
}

.login-seal {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, .65);
}

.login-seal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-lockup-name {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  line-height: 1.15;
}

.login-lockup-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--blue-lt);
  margin-top: 3px;
}

.login-tagline {
  position: relative;
  z-index: 1;
  margin: 12px auto 0;
  max-width: 300px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--blue-pale);
}

.login-body {
  padding: 20px 20px 18px;
}

.login-field-group {
  margin-bottom: 14px;
}

.login-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login-control {
  position: relative;
}

.login-control .lc-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--faint);
  pointer-events: none;
  display: flex;
}

.login-control .lc-icon svg {
  width: 17px;
  height: 17px;
}

.login-control select,
.login-control input {
  width: 100%;
  height: 42px;
  padding: 10px 38px 10px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--off);
  outline: none;
  font-size: 13.5px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

.login-control select {
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-control input::placeholder {
  color: var(--faint);
}

.login-control select:focus,
.login-control input:focus {
  border-color: var(--blue2);
  box-shadow: 0 0 0 3px var(--blue-soft);
  background: #fff;
}

.login-control select.invalid,
.login-control input.invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.login-control .lc-chev {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
  display: flex;
}

.login-control .lc-chev svg {
  width: 15px;
  height: 15px;
}

.login-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  cursor: pointer;
}

.login-eye:hover {
  color: var(--blue);
  background: #fff;
}

.login-eye svg {
  width: 17px;
  height: 17px;
}

.login-err {
  color: var(--red);
  font-size: 12.5px;
  margin-top: 5px;
  font-weight: 500;
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 16px;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue-dk);
  cursor: pointer;
  margin: 0;
}

.login-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
}

.login-link:hover {
  color: var(--blue-dk);
  text-decoration: underline;
}

.login-signin {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--blue-mid) 0%, var(--blue-dk) 100%);
  color: #fff;
  font-size: 14.5px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(35, 92, 144, .28);
  transition: filter .15s, transform .1s;
  cursor: pointer;
  font-family: inherit;
}

.login-signin:hover {
  filter: brightness(1.07);
}

.login-signin:active {
  transform: translateY(1px);
}

.login-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.login-or::before,
.login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-or span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
}

.login-activate {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  background: #fff;
  color: var(--blue-dk);
  font-size: 14px;
  font-weight: 700;
  transition: border-color .15s, background .15s;
  cursor: pointer;
  font-family: inherit;
}

.login-activate:hover {
  border-color: var(--blue);
  background: var(--off);
}

.login-terms {
  background: var(--off);
  border-top: 1px solid var(--border);
  padding: 13px 22px 15px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.login-terms .login-link {
  font-size: 11.5px;
}

.login-under {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .72);
}

.login-under .login-link {
  color: rgba(255, 255, 255, .85);
  font-size: 12.5px;
  font-weight: 500;
}

.login-under .login-link:hover {
  color: #fff;
}

.login-back {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 6px;
}

.login-back svg {
  width: 14px;
  height: 14px;
}

.login-back:hover {
  color: #fff;
  text-decoration: underline;
}

.role-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--blue-soft);
  color: var(--blue);
}

.role-tag.admin {
  background: var(--orange-soft);
  color: var(--orange-dark);
}

/* ---------- App shell ---------- */
#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: min(266px, 88vw);
  flex: none;
  background: linear-gradient(180deg, var(--blue-dk) 0%, var(--blue) 100%);
  border-right: 1px solid rgba(117, 172, 216, .35);
  color: #fff;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.brand {
  padding: 26px 20px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(117, 172, 216, .35);
}

.brand .mark {
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
}

.brand .mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: .12em;
  font-weight: 800;
  color: #fff;
  font-family: "DM Sans", sans-serif;
}

.brand .bsub {
  font-family: "Playfair Display", serif;
  font-style: italic;
  color: var(--blue-lt);
  font-size: 14.5px;
  margin-top: 1px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 8px;
}

.nav-group {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--blue-lt);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9.5px 11px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, .88);
  text-align: left;
  margin-bottom: 2px;
  min-width: 0;
  overflow: hidden;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--blue-lt);
}

.nav-item:hover {
  background: rgba(255, 255, 255, .10);
  color: #fff;
}

.nav-item:hover svg {
  color: #fff;
}

.nav-item.active {
  background: #fff;
  color: var(--blue-dk);
  font-weight: 700;
  box-shadow: inset 4px 0 0 var(--gold);
}

.nav-item.active svg {
  color: var(--blue-dk);
}

.side-user {
  border-bottom: 1px solid rgba(117, 172, 216, .35);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.nav-group:first-child {
  padding-top: 8px;
}

.side-user .su-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue-lt);
  flex: none;
}

.side-user .su-name {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.25;
  color: #fff;
  overflow-wrap: anywhere;
}

.side-user .su-role {
  font-size: 12px;
  color: var(--blue-lt);
  overflow-wrap: anywhere;
}

.main {
  flex: 1;
  margin-left: 266px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 26px;
}

.topbar .t-title {
  min-width: 0;
}

.topbar .t-title .crumbs {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .t-title h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .spacer {
  flex: 1;
}

.topbar .global-search {
  width: min(340px, 38vw);
}

.bell-wrap {
  position: relative;
}

.bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

.bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(360px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 70;
}

.bell-panel .bp-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bell-panel .bp-head span {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
}

.bp-item {
  display: flex;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  align-items: flex-start;
  cursor: pointer;
  transition: background .15s ease;
}

.bp-item:last-child {
  border-bottom: none;
}

.bp-item:hover {
  background: var(--mist);
}

.bp-item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: var(--mist);
}

.bp-item .bp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
}

.bp-item .bp-text {
  font-size: 13px;
  color: var(--ink2);
  line-height: 1.45;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bp-item .bp-text b {
  color: var(--ink);
}

.bp-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* On narrow screens the bell sits left of centre (title collapses,
         Add Book / Log out take the right side), so a panel right-aligned
         to the bell would slide off the left edge. Pin it to the viewport
         instead so every notification stays fully visible and tappable. */
@media (max-width:860px) {
  .bell-wrap .bell-panel {
    position: fixed;
    top: 64px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}

/* Notification click-through target: temporary pulse so the user can
         see exactly which record a notification referred to. Background +
         box-shadow only ΓÇö no layout shift. Removed by JS after 2s.
         Table rows: the whole row is ONE continuous strip ΓÇö every cell
         shares the same pulsing background, middle cells carry only the
         shared top/bottom edge (no left/right inset shadow, no per-cell
         border, no vertical dividers), and the row outline is completed
         by a left edge on the first cell and a right edge on the last
         cell only. Cards keep the single-box pulse (notifPulse). */
[data-notif-target] {
  scroll-margin-top: 96px;
  scroll-margin-bottom: 28px;
}

.notif-highlight {
  background-color: #FDEEDF !important;
  box-shadow: 0 0 0 2px var(--gold), 0 6px 18px rgba(217, 122, 69, .22) !important;
  animation: notifPulse 2s ease-in-out;
}

tr.notif-highlight {
  background-color: transparent !important;
  box-shadow: none !important;
  animation: none;
}

tr.notif-highlight td {
  background-color: #FDEEDF !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom-color: transparent !important;
  animation: notifPulseCell 2s ease-in-out;
}

tr.notif-highlight td:first-child {
  animation-name: notifPulseCellFirst;
}

tr.notif-highlight td:last-child {
  animation-name: notifPulseCellLast;
}

tr.notif-highlight td:first-child:last-child {
  animation-name: notifPulseCellOnly;
}

@keyframes notifPulse {
  0% {
    background-color: transparent;
    box-shadow: 0 0 0 0 rgba(217, 122, 69, 0);
  }

  18% {
    background-color: #FDEEDF;
    box-shadow: 0 0 0 3px rgba(217, 122, 69, .60), 0 6px 18px rgba(217, 122, 69, .22);
  }

  38% {
    background-color: #EEF4FA;
    box-shadow: 0 0 0 1px rgba(63, 140, 204, .38);
  }

  58% {
    background-color: #FDEEDF;
    box-shadow: 0 0 0 3px rgba(217, 122, 69, .60), 0 6px 18px rgba(217, 122, 69, .22);
  }

  78% {
    background-color: #FFF7F0;
    box-shadow: 0 0 0 1px rgba(217, 122, 69, .30);
  }

  100% {
    background-color: transparent;
    box-shadow: 0 0 0 0 rgba(217, 122, 69, 0);
  }
}

/* Middle cells: shared background + top/bottom edge only ΓÇö the
         inset shadows are horizontal (0 offset-x), so no vertical line
         can appear between cells and the strip reads as one piece. */
@keyframes notifPulseCell {
  0% {
    background-color: transparent;
    box-shadow: inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }

  18% {
    background-color: #FDEEDF;
    box-shadow: inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  38% {
    background-color: #EEF4FA;
    box-shadow: inset 0 2px 0 rgba(63, 140, 204, .38), inset 0 -2px 0 rgba(63, 140, 204, .38);
  }

  58% {
    background-color: #FDEEDF;
    box-shadow: inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  78% {
    background-color: #FFF7F0;
    box-shadow: inset 0 2px 0 rgba(217, 122, 69, .30), inset 0 -2px 0 rgba(217, 122, 69, .30);
  }

  100% {
    background-color: transparent;
    box-shadow: inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }
}

/* First cell: same strip + the row's single left edge. */
@keyframes notifPulseCellFirst {
  0% {
    background-color: transparent;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }

  18% {
    background-color: #FDEEDF;
    box-shadow: inset 2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  38% {
    background-color: #EEF4FA;
    box-shadow: inset 2px 0 0 rgba(63, 140, 204, .38), inset 0 2px 0 rgba(63, 140, 204, .38), inset 0 -2px 0 rgba(63, 140, 204, .38);
  }

  58% {
    background-color: #FDEEDF;
    box-shadow: inset 2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  78% {
    background-color: #FFF7F0;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, .30), inset 0 2px 0 rgba(217, 122, 69, .30), inset 0 -2px 0 rgba(217, 122, 69, .30);
  }

  100% {
    background-color: transparent;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }
}

/* Last cell: same strip + the row's single right edge. */
@keyframes notifPulseCellLast {
  0% {
    background-color: transparent;
    box-shadow: inset -2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }

  18% {
    background-color: #FDEEDF;
    box-shadow: inset -2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  38% {
    background-color: #EEF4FA;
    box-shadow: inset -2px 0 0 rgba(63, 140, 204, .38), inset 0 2px 0 rgba(63, 140, 204, .38), inset 0 -2px 0 rgba(63, 140, 204, .38);
  }

  58% {
    background-color: #FDEEDF;
    box-shadow: inset -2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  78% {
    background-color: #FFF7F0;
    box-shadow: inset -2px 0 0 rgba(217, 122, 69, .30), inset 0 2px 0 rgba(217, 122, 69, .30), inset 0 -2px 0 rgba(217, 122, 69, .30);
  }

  100% {
    background-color: transparent;
    box-shadow: inset -2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }
}

/* Single-cell row: all four edges on the one cell. */
@keyframes notifPulseCellOnly {
  0% {
    background-color: transparent;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, 0), inset -2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }

  18% {
    background-color: #FDEEDF;
    box-shadow: inset 2px 0 0 var(--gold), inset -2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  38% {
    background-color: #EEF4FA;
    box-shadow: inset 2px 0 0 rgba(63, 140, 204, .38), inset -2px 0 0 rgba(63, 140, 204, .38), inset 0 2px 0 rgba(63, 140, 204, .38), inset 0 -2px 0 rgba(63, 140, 204, .38);
  }

  58% {
    background-color: #FDEEDF;
    box-shadow: inset 2px 0 0 var(--gold), inset -2px 0 0 var(--gold), inset 0 2px 0 var(--gold), inset 0 -2px 0 var(--gold);
  }

  78% {
    background-color: #FFF7F0;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, .30), inset -2px 0 0 rgba(217, 122, 69, .30), inset 0 2px 0 rgba(217, 122, 69, .30), inset 0 -2px 0 rgba(217, 122, 69, .30);
  }

  100% {
    background-color: transparent;
    box-shadow: inset 2px 0 0 rgba(217, 122, 69, 0), inset -2px 0 0 rgba(217, 122, 69, 0), inset 0 2px 0 rgba(217, 122, 69, 0), inset 0 -2px 0 rgba(217, 122, 69, 0);
  }
}

.content {
  padding: 26px;
  width: 100%;
}

.hamburger {
  display: none;
}

/* ---------- Generic panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.panel-head .ph-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.panel-body {
  padding: 20px;
}

/* Grid tracks use minmax(0,ΓÇª) and every grid/flex child gets
         min-width:0, so a wide child (a 640px-min table inside a panel)
         can never force its column ΓÇö and with it the whole page ΓÇö wider
         than the viewport. The table scrolls inside its own .table-wrap
         instead of stretching the layout. */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.grid-side {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.cat-tree-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.grid-2>*,
.grid-side>*,
.cat-tree-grid>*,
.catalog-layout>*,
.stack>* {
  min-width: 0;
}

@media (max-width:900px) {
  .cat-tree-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge.green {
  background: var(--green-soft);
  color: var(--green);
}

.badge.red {
  background: var(--red-soft);
  color: var(--red);
}

.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.gray {
  background: var(--mist);
  color: var(--muted);
}

.badge.orange {
  background: var(--orange-soft);
  color: var(--orange-dark);
}

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

.small {
  font-size: 12.5px;
}

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--line2);
  margin-bottom: 8px;
}

.empty-state .es-title {
  font-family: "Playfair Display", serif;
  font-size: 18px;
  color: var(--ink2);
  font-weight: 600;
}

/* ---------- KPI cards ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
}

.kpi.orange::before {
  background: var(--orange);
}

.kpi.green::before {
  background: var(--green);
}

.kpi.red::before {
  background: var(--red);
}

.kpi .k-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.kpi .k-label svg {
  width: 15px;
  height: 15px;
}

.kpi .k-value {
  font-family: "Playfair Display", serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  margin-top: 4px;
}

.kpi .k-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

button.kpi {
  font: inherit;
  color: var(--ink);
  text-align: left;
  width: 100%;
}

button.kpi:hover {
  border-color: var(--blue2);
}

.ann-btn {
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  display: block;
}

.attn-btn {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}

.attn-btn:hover {
  background: var(--mist);
}

.topic-x {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 0 0 0 5px;
  font-size: 12px;
  line-height: 1;
}

.topic-x:hover {
  color: var(--red);
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 640px;
}

table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  white-space: nowrap;
}

table.data th.sortable {
  cursor: pointer;
  user-select: none;
}

table.data th.sortable:hover {
  color: var(--blue);
}

table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink2);
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data tbody tr {
  transition: background .12s;
}

table.data tbody tr:hover {
  background: var(--mist);
}

td .t-strong {
  color: var(--ink);
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.mini-btn {
  border: 1px solid var(--line2);
  background: var(--surface);
  color: var(--ink2);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.mini-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.mini-btn svg {
  width: 13px;
  height: 13px;
}

.mini-btn.red:hover {
  border-color: var(--red);
  color: var(--red);
}

.thumb-cover {
  width: 34px;
  height: 46px;
  border-radius: 3px 5px 5px 3px;
  flex: none;
  position: relative;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .92);
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 14px;
}

.cell-book {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

/* ---------- Catalog ---------- */
.catalog-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* Sticky Categories card: its top offset clears the sticky bar of the
         view it sits in (measured bar height + 16px gap) so the card never
         slides under the bar while scrolling ΓÇö signed-in topbar is 75px,
         guest topbar is 73px on desktop. Static (non-sticky) at Γëñ1080px. */
.tree-panel {
  position: sticky;
  top: 91px;
}

#guestView .tree-panel {
  top: 16px;
}

#guestView .tree-panel {
  top: 64px;
}

/* Sticky Library Catalog Header */
#guestView .guest-sec-head {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  padding: 10px 0 6px 0;
  margin: 0;
}

/* Sticky Library Catalog Filter Controls */
.catalog-sticky-controls {
  position: sticky;
  top: 75px;
  z-index: 20;
  background: var(--bg);
  padding: 8px 0 12px 0;
  padding: 6px 0 10px 0;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

#guestView .catalog-sticky-controls {
  top: 16px;
  top: 64px;
}

.catalog-sticky-controls>.pill-row {
  margin-bottom: 10px !important;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  gap: 8px;
  padding: 2px 0 6px 0;
  margin-bottom: 8px !important;
}

.catalog-sticky-controls>.pill-row::-webkit-scrollbar {
  display: none;
}

.catalog-sticky-controls>.pill-row .pill {
  flex: 0 0 auto;
  white-space: nowrap;
}

.catalog-sticky-controls .catalog-toolbar {
  margin-bottom: 0;
}

@media (max-width:860px) {

  #guestView .guest-sec-head,
  .catalog-sticky-controls {
    position: static;
    border-bottom: none;
    padding: 0;
  }
}

/* Scroll compensation for scrollIntoView landings (hero Browse Books,
         pagination page changes, search Enter jumps): the target's
         scroll-margin-top gives a small breathing gap below the viewport
         top. Guest view: the guest topbar is now in normal static flow
         (position:relative, scrolls away with the page) so no bar ever
         overlays the catalog heading at any scroll position or viewport
         height ΓÇö guest margin is just 20px. Signed-in view keeps its
         sticky-bar compensation: 75px desktop, 66px at Γëñ860px (+16px gap). */
#guestCatalog {
  scroll-margin-top: 20px;
}

#catalogTop {
  scroll-margin-top: 91px;
}

/* Fit at the scroll limit (guest view): the guest topbar is no longer
         sticky, so nothing overlays the catalog at the scroll limit at any
         viewport height. The earlier spacing trim (pager 12px) is kept as
         harmless tightening so heading, filters, books, pager and footer
         fit compactly. */
#guestView .pager {
  margin-top: 12px;
}

@media (max-width:860px) {
  #guestCatalog {
    scroll-margin-top: 20px;
  }

  #catalogTop {
    scroll-margin-top: 82px;
  }
}

@media (max-width:640px) {
  #guestCatalog {
    scroll-margin-top: 20px;
  }
}

.tree-cat {
  border-bottom: 1px solid var(--line);
}

.tree-cat:last-child {
  border-bottom: none;
}

.tree-cat-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink2);
  text-align: left;
}

.tree-cat-btn svg {
  width: 14px;
  height: 14px;
  color: var(--faint);
  transition: transform .15s;
}

.tree-cat.open .tree-cat-btn svg {
  transform: rotate(90deg);
}

.tree-cat-btn .t-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

.tree-cat-btn.active {
  color: var(--blue);
}

.tree-subs {
  display: none;
  padding: 0 10px 10px 20px;
}

.tree-cat.open .tree-subs {
  display: block;
}

.tree-sub-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 7px 8px 3px;
}

.tree-topic {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 5px 8px;
  font-size: 13.5px;
  color: var(--ink2);
  border-radius: 6px;
}

.tree-topic:hover {
  background: var(--mist);
  color: var(--blue);
}

.tree-topic.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--line2);
  background: var(--surface);
  color: var(--ink2);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: all .13s;
}

.pill:hover {
  border-color: var(--blue);
}

.pill.active {
  background: var(--gold-dk);
  border-color: var(--gold-dk);
  color: #fff;
}

.pill.active.orange-p {
  background: var(--gold-dk);
  border-color: var(--gold-dk);
}

.catalog-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}

.catalog-toolbar .grow {
  flex: 1;
  min-width: 180px;
}

.catalog-toolbar select {
  padding: 9px 10px;
  border: 1px solid var(--line2);
  border-radius: 9px;
  background: var(--surface);
}

.pager {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  margin-top: 22px;
}

/* Issued Books (circulation) pagination footer: showing line on the
         left, pager right-aligned ΓÇö the table is paged at CIRC_PAGE_SIZE
         rows so the whole panel fits the viewport with no inner scroll. */
.circ-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding: 13px 20px 15px;
  border-top: 1px solid var(--line);
}

.circ-foot .pager {
  margin-top: 0;
}

.circ-foot .cf-showing {
  font-size: 12.5px;
  color: var(--muted);
}

/* Paged tables (Issued Books + the fit10 admin tables) run slightly
         tighter rows and covers so all 10 rows of a page sit inside the
         panel without scrolling the content. */
table.data.circ-table td,
table.data.fit10 td {
  padding-top: 9px;
  padding-bottom: 9px;
}

table.data.circ-table .thumb-cover,
table.data.fit10 .thumb-cover {
  width: 30px;
  height: 40px;
  font-size: 12px;
}

@media (max-width:640px) {
  .circ-foot {
    justify-content: flex-end;
  }

  .circ-foot .cf-showing {
    width: 100%;
  }
}

.pg-btn {
  min-width: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--blue-dk);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}

.pg-btn:hover:not(:disabled):not(.active) {
  background: var(--off);
}

.pg-btn.active {
  background: var(--blue-dk);
  border-color: var(--blue-dk);
  color: #fff;
  cursor: default;
}

.pg-btn:disabled {
  color: var(--muted);
  opacity: .55;
  cursor: not-allowed;
}

.view-toggle {
  display: flex;
  border: 1px solid var(--line2);
  border-radius: 9px;
  overflow: hidden;
}

.view-toggle button {
  border: none;
  background: var(--surface);
  padding: 8px 11px;
  color: var(--muted);
  display: flex;
}

.view-toggle button svg {
  width: 16px;
  height: 16px;
}

.view-toggle button.active {
  background: var(--blue-dk);
  color: #fff;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 18px;
}

/* "New in the library" dashboard strip: narrower min column than the
         catalog so its four cards sit in one row inside the dashboard panel. */
.new-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.book-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  padding: 0;
  width: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line2);
}

.book-cover {
  height: 220px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 14px 14px 22px;
  background: linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
  border-bottom: 1px solid var(--line);
  overflow: visible;
  perspective: 580px;
  perspective-origin: 20% 45%;
}

.book-cover .bc-fmt {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(29, 53, 87, .9);
  border: 1px solid rgba(255, 255, 255, .45);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  z-index: 4;
}

/* 3D Isometric Book View */
.book {
  --book-w: 136px;
  /* cover width */
  --book-h: 170px;
  /* cover height — keep the cover's ratio */
  --depth: 22px;
  /* spine thickness */
  --lift: 12px;
  /* how far the back edge lifts up */
  position: relative;
  width: var(--book-w);
  height: var(--book-h);
  margin: var(--lift) 0 0 var(--depth);
  filter: drop-shadow(14px 18px 14px rgba(25, 40, 58, .35));
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2, .9, .25, 1), filter .4s ease;
  background: var(--c2, #184c8a);
  border-radius: 0 4px 4px 0;
}

/* Back cover decorative gold border & rim framing */
.book-card .book::after {
  content: "";
  position: absolute;
  inset: 3px 5px 3px 0;
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-left: none;
  border-radius: 0 3px 3px 0;
  pointer-events: none;
  z-index: 1;
}

.book-card .book {
  transform-style: preserve-3d;
  animation: lib-book-drop 1s cubic-bezier(.2, .9, .3, 1.12) var(--d, 0s) backwards;
}

/* Interior Ruled Book Page with Margins, Ruled Lines and Gutter Shadow */
.book-card .book::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 4px 10px 4px 0;
  border-radius: 0 2px 2px 0;
  pointer-events: none;
  background-color: #faf5e6;
  background-image:
    linear-gradient(90deg, rgba(20, 24, 33, 0.45) 0, rgba(20, 24, 33, 0.12) 10px, transparent 26px),
    linear-gradient(90deg, transparent calc(100% - 10px), rgba(160, 140, 120, 0.35) calc(100% - 10px), rgba(160, 140, 120, 0.35) calc(100% - 9px), transparent calc(100% - 9px)),
    repeating-linear-gradient(
      transparent 0,
      transparent 7px,
      rgba(100, 85, 70, 0.18) 7px,
      rgba(100, 85, 70, 0.18) 8.5px
    );
  background-size: 100% 100%, 100% 100%, calc(100% - 18px) calc(100% - 22px);
  background-position: left top, left top, 10px 12px;
  background-repeat: no-repeat;
  box-shadow:
    inset -1px 0 2px rgba(0, 0, 0, 0.14),
    inset 0 0 4px rgba(0, 0, 0, 0.06);
  transition: box-shadow .5s ease;
}

.book-card:hover .book::before {
  box-shadow:
    inset 22px 0 20px -6px rgba(18, 28, 42, 0.45),
    inset -1px 0 2px rgba(0, 0, 0, 0.14);
}

@keyframes lib-book-drop {
  from {
    transform: translateY(-90px) rotateY(115deg) scale(.9);
  }
}

.book-card:hover .book {
  transform: translateY(-8px) scale(1.02);
  filter: drop-shadow(20px 26px 22px rgba(25, 40, 58, .48));
}

/* Front Cover Assembly with Crease Hinge */
.book .front {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: none;
  overflow: visible;
  transform-style: preserve-3d;
  transform-origin: 4px center;
  transition: transform .55s cubic-bezier(.16, .92, .24, 1), filter .5s ease;
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
}

/* Real front cover face & artwork */
.book .front .ld-fc {
  position: absolute;
  inset: 0;
  border-radius: 1px 4px 4px 1px;
  overflow: hidden;
  background: #1e293b;
  box-shadow: inset 4px 0 6px rgba(0, 0, 0, .28);
  transform-style: preserve-3d;
}

.book .front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Spine crease shadow on the cover */
.book .front .ld-fc::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.45) 0px,
    rgba(0, 0, 0, 0.08) 4px,
    rgba(255, 255, 255, 0.32) 7px,
    rgba(0, 0, 0, 0.16) 10px,
    transparent 22px
  );
}

/* Book card hover — opens the front cover smoothly */
.book-card:hover .book .front {
  transform: rotateY(-50deg) rotateZ(1.5deg) rotateX(1deg);
  filter: drop-shadow(14px 6px 12px rgba(10, 20, 35, 0.52));
}

/* Detail modal static cover (unanimated) */
.book-detail-view .front {
  transform: none !important;
  filter: none !important;
}

.book-detail-view .front .ld-fc {
  position: absolute;
  inset: 0;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  background: #1e293b;
  box-shadow: inset 6px 0 8px rgba(0, 0, 0, .32);
}

.book .ld-fi {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  background: linear-gradient(135deg, #f4edda, #e4d9bd);
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -6px 0 8px rgba(0, 0, 0, .12);
}

/* spine ΓÇö skewY(28deg) because atan(lift/depth) = atan(16/30) Γëê 28┬░ */
.book .spine {
  position: absolute;
  z-index: 2;
  left: calc(var(--depth) * -1);
  top: 0;
  width: var(--depth);
  height: 100%;
  background: linear-gradient(90deg, #232228, #3a3841 70%, #2c2a33);
  transform: skewY(28deg);
  transform-origin: right center;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14px;
  overflow: hidden;
}

.book .spine span {
  writing-mode: vertical-rl;
  color: #e4e4e8;
  font: 700 8.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: .06em;
  white-space: nowrap;
  text-transform: uppercase;
  max-height: calc(100% - 44px);
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.book .spine::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  height: 5px;
  background: #D97A45;
}

/* gold band */
/* pages on top ΓÇö skewX(62deg) because atan(depth/lift) = atan(30/16) Γëê 62┬░ */
.book .pages {
  position: absolute;
  z-index: 1;
  left: 0;
  top: calc(var(--lift) * -1);
  width: 100%;
  height: var(--lift);
  transform: skewX(62deg);
  transform-origin: bottom left;
  background: repeating-linear-gradient(180deg, #f6f2e6 0 2px, #c9c2ae 2px 3px);
  border: 1px solid #b8b29c;
  border-bottom: none;
}

/* Detail modal stage & full-size 3D book */
.detail-cover {
  min-height: 280px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 24px 24px 36px;
  background: radial-gradient(ellipse at 50% 65%, #2a3d54 0%, #172433 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.detail-cover .book.book-detail-view {
  --book-w: 200px;
  --book-h: 247px;
  --depth: 30px;
  --lift: 16px;
  filter: drop-shadow(16px 24px 20px rgba(0, 0, 0, .6));
}

.detail-cover .book.book-detail-view .spine {
  padding-top: 18px;
}

.detail-cover .book.book-detail-view .spine span {
  font-size: 10px;
  max-height: calc(100% - 50px);
}

.detail-cover .bc-fmt {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .45);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
  z-index: 4;
}

/* Mini cover thumbnail (books with a coverImg field) */
.thumb-wrap {
  position: relative;
  display: inline-flex;
  width: 30px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
}

.thumb-wrap img.thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  padding: 0;
  z-index: 2;
}

img.thumb-img {
  object-fit: cover;
  display: block;
  padding: 0;
  box-shadow: 0 1px 4px rgba(35, 53, 72, .25);
  background: var(--mist);
}

.book-meta {
  padding: 13px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.book-meta .bm-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.3;
}

.book-meta .bm-author {
  font-size: 12.5px;
  color: var(--muted);
}

.book-meta .bm-foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  gap: 16px;
  align-items: center;
  text-align: left;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.book-row:hover {
  border-color: var(--blue2);
}

.book-row .thumb-cover {
  width: 44px;
  height: 60px;
  font-size: 17px;
}

.book-row .br-main {
  flex: 1;
  min-width: 0;
}

.book-row .br-title {
  font-weight: 700;
  color: var(--ink);
  font-size: 15px;
}

.book-row .br-sub {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Modal ---------- */
/* Scroll lock (JS toggles .scroll-locked on html+body while a modal is open):
         overflow:hidden stops wheel/keyboard scrolling; position:fixed on body
         also stops touch scrolling on mobile. JS sets body top to -scrollY so
         the page does not jump, and restores the position on close.
         Shift + white-strip guard: html reserves its scrollbar gutter at all
         times (see the base html rule), and lockScroll() additionally pins
         the fixed body's width to its exact pre-lock pixel width ΓÇö a fixed
         body's width:100% resolves against a containing block whose width
         varies with the scrollbar/gutter state, which otherwise narrows
         the background layout by the scrollbar width while a modal is
         open. Together they keep every background element at the exact
         same geometry before, during, and after a modal.
         The white-strip guard: while locked, html RELEASES its gutter
         (html.scroll-locked below). Nothing in the page can paint over a
         reserved gutter ΓÇö fixed elements clip at the scrollport edge and
         only the canvas background shows there, as a pale strip beside
         the dimmed backdrop. Releasing the gutter for the duration of
         the lock widens the viewport the overlay is sized against back
         to the full window width, so the overlay's 100vw backdrop color
         and blur cover the strip area too. This cannot shift the
         background: every content element lives inside the body, whose
         width lockScroll() pins to its pre-lock pixels, so the wider
         viewport only gives the fixed overlay more room ΓÇö the layout
         itself never sees it. The overlay reserves its own gutter, so
         the dialog stays put when its internal scrollbar
         appears/disappears between stacked modals. */
html.scroll-locked {
  scrollbar-gutter: auto;
}

html.scroll-locked,
body.scroll-locked {
  overflow: hidden !important;
}

body.scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 36, 54, .55);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 16px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
}

.modal.wide {
  max-width: 760px;
}

[hidden] {
  display: none !important;
}

[data-admin-modal] {
  position: fixed;
  inset: 0;
  z-index: 9999 !important;
}

[data-admin-modal][hidden] {
  display: none !important;
}

.modal-overlay,
#modalRoot .modal-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 36, 54, .55);
  backdrop-filter: blur(3px);
  z-index: 9999 !important;
  display: flex !important;
  align-items: flex-start;
  justify-content: center;
  padding: 26px 16px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.modal-overlay .modal,
#modalRoot .modal,
[data-admin-modal] .modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
  display: block !important;
  position: relative !important;
}

.modal.wide,
.modal-overlay .modal.wide {
  max-width: 760px;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.985);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  flex: 1;
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-foot {
  padding: 0 24px 22px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.detail-cover {
  height: 250px;
  border-radius: 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 20px 18px 30px;
  color: #fff;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: inset 0 -4px 0 var(--gold);
}

.detail-cover::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 11px;
  background: rgba(0, 0, 0, .22);
}

.detail-cover::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .25);
}

.detail-cover .bc-title {
  font-family: "Playfair Display", serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.2;
  max-width: 85%;
}

.detail-cover .bc-cat {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .85;
}

.detail-cover .bc-author {
  font-size: 14px;
  opacity: .9;
  font-style: italic;
  font-family: "Playfair Display", serif;
  margin-top: 6px;
}

.detail-cover .bc-fmt {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin: 16px 0;
}

.spec-grid .sp .sp-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}

.spec-grid .sp .sp-v {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.success-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dk);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 12px;
}

.success-icon svg {
  width: 28px;
  height: 28px;
}

.confirm-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 12px;
}

.confirm-icon svg {
  width: 28px;
  height: 28px;
}

/* ---------- Log out confirmation modal ----------
         Simple alert-style card (iOS-alert proportions) in ACTS
         colors, scoped under .modal.logout and used ONLY by
         authLogoutConfirm (login success is the toast below), so no
         other modal changes. One compact white card, min(86vw, 320px)
         at every viewport, vertically centered in the overlay,
         overflow hidden so the action bar clips to the 16px radius.
         No icon badge, no header row, no gold rule, no X button:
         just centered title + message, then a bottom action bar
         split into two equal text buttons by hairlines. */
.modal.logout {
  width: min(86vw, 320px);
  max-width: 320px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  align-self: center;
}

.modal.logout .logout-content {
  padding: 22px 20px 18px;
  text-align: center;
}

.modal.logout .logout-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-dk);
  line-height: 1.25;
  text-align: center;
}

.modal.logout .logout-msg {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  text-align: center;
}

.modal.logout .logout-actions {
  display: flex;
  border-top: 1px solid var(--border);
}

.modal.logout .logout-btn {
  flex: 1 1 50%;
  width: 50%;
  height: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: none;
  border-radius: 0;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.2;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.modal.logout .logout-btn-cancel {
  color: var(--muted);
  font-weight: 500;
  border-right: 1px solid var(--border);
}

.modal.logout .logout-btn-confirm {
  color: var(--blue);
  font-weight: 700;
}

.modal.logout .logout-btn:hover,
.modal.logout .logout-btn:active {
  background: var(--off);
}

.modal.logout .logout-btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

/* ---------- Login-success toast (bottom-right, non-modal) ----------
         Used ONLY by the login-success notification. One compact card:
         success message first, then role + ID details below a divider.
         No backdrop, no scroll lock, no Done button. The Log out
         confirmation above is a separate compact modal. */
#toastRoot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  width: 360px;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

#toastRoot:empty {
  display: none;
}

.login-toast {
  pointer-events: auto;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(35, 92, 144, .18), 0 4px 12px rgba(35, 92, 144, .10);
  padding: 16px 40px 15px 16px;
  animation: loginToastIn .22s ease;
}

@keyframes loginToastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.lt-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.lt-badge {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--blue-dk);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lt-badge svg {
  width: 18px;
  height: 18px;
}

.lt-text {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.lt-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.lt-welcome {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.lt-welcome b {
  color: var(--ink2);
  font-weight: 600;
}

.lt-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.lt-x:hover {
  background: var(--off);
  color: var(--blue-dk);
}

.lt-x svg {
  width: 14px;
  height: 14px;
}

.lt-divider {
  height: 1px;
  background: var(--border);
  margin: 13px 0 12px 47px;
}

.lt-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-left: 47px;
}

.lt-field {
  min-width: 0;
}

.lt-field .lt-k {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.lt-field .lt-v {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width:480px) {
  #toastRoot {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }

  .lt-details {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Announcements / misc ---------- */
.ann-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: 10px;
  padding: 15px 18px;
  background: var(--surface);
}

.ann-card h4 {
  margin: 0 0 4px;
  font-size: 16px;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
}

.ann-card p {
  margin: 0;
  color: var(--ink2);
  font-size: 13.5px;
}

.ann-card .ann-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.bar-sub {
  margin: -2px 0 6px 120px;
}

.bar-track {
  height: 10px;
  background: var(--mist);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
}

.attn-item {
  display: flex;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.attn-item:last-child {
  border-bottom: none;
}

.attn-item .a-ic {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.attn-item .a-ic svg {
  width: 16px;
  height: 16px;
}

.attn-item .a-tx {
  font-size: 13.5px;
  color: var(--ink2);
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.attn-item .a-tx b {
  color: var(--ink);
}

/* ---------- Reader ---------- */
.reader-shell {
  max-width: 1120px;
  margin: 0 auto;
}

.reader-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.reader-toc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 16px 12px;
  position: sticky;
  top: 16px;
}

.reader-toc h4 {
  margin: 2px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.reader-toc .toc-book {
  margin: 0 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.toc-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink2);
  text-align: left;
  cursor: pointer;
}

.toc-item:hover {
  background: var(--mist);
}

.toc-item.active {
  background: var(--blue-soft);
  color: var(--blue-dk);
  font-weight: 700;
}

.toc-item .toc-label {
  flex: 1;
  line-height: 1.35;
}

.toc-item .toc-pg {
  font-size: 12px;
  color: var(--faint);
  font-weight: 600;
}

.toc-item.active .toc-pg {
  color: var(--blue-dk);
}

.reader-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 52px 58px;
  min-height: 62vh;
}

.reader-page .rp-chap {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--orange-dark);
  text-align: center;
  margin-bottom: 8px;
}

.reader-page h2 {
  text-align: center;
  font-size: calc(27px * var(--rps, 1));
  margin: 0 0 26px;
}

.reader-page p {
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(16.5px * var(--rps, 1));
  line-height: 1.85;
  color: var(--ink2);
  margin: 0 0 18px;
  text-align: justify;
}

.reader-page p:first-of-type::first-letter {
  font-family: "Playfair Display", serif;
  font-size: calc(46px * var(--rps, 1));
  float: left;
  line-height: .85;
  padding: 4px 10px 0 0;
  color: var(--blue);
  font-weight: 700;
}

.reader-page.nodrop p:first-of-type::first-letter {
  font-family: inherit;
  font-size: inherit;
  float: none;
  line-height: inherit;
  padding: 0;
  color: inherit;
  font-weight: inherit;
}

.rp-part {
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  margin: -14px 0 22px;
  font-style: italic;
}

.rp-cover-author {
  text-align: center;
  font-size: calc(17px * var(--rps, 1));
  color: var(--ink2);
  margin-bottom: 6px;
}

.rp-cover-meta {
  text-align: center;
  font-size: 13px;
  color: var(--faint);
  margin-bottom: 24px;
}

.rp-gold-rule {
  width: 64px;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
  margin: 0 auto 24px;
}

.rp-cover-note {
  max-width: 520px;
  margin: 0 auto !important;
  text-align: center !important;
}

.toc-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 6px;
  font: inherit;
  font-size: calc(15px * var(--rps, 1));
  color: var(--ink2);
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.toc-row:hover {
  color: var(--blue-dk);
  background: var(--mist);
}

.toc-row .dots {
  flex: 1;
  border-bottom: 2px dotted var(--line2);
  transform: translateY(-4px);
}

.toc-row .toc-row-pg {
  font-weight: 700;
  color: var(--blue-dk);
  font-size: 13.5px;
}

.rp-end-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 26px;
}

.reader-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.reader-jump {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--muted);
}

.reader-jump input {
  width: 62px;
  padding: 7px 8px;
  border: 1px solid var(--line2);
  border-radius: 7px;
  font: inherit;
  font-size: 13.5px;
  text-align: center;
  color: var(--ink);
}

.reader-font {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.reader-font .btn {
  font-weight: 700;
}

.detail-toc {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.detail-toc h4 {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.detail-toc .toc-row {
  font-size: 14px;
  padding: 7px 4px;
}

.reader-head-thumb {
  width: 46px;
  height: 57px;
  object-fit: cover;
  display: block;
  border-radius: 3px 5px 5px 3px;
  box-shadow: 0 1px 5px rgba(35, 53, 72, .3);
  flex: none;
}

.reader-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.reader-head-meta {
  flex: 1;
  min-width: 180px;
}

.reader-head-title {
  font-weight: 700;
}

/* Mobile-only Contents toggle bar (see the Γëñ860px reader block):
         hidden on desktop, where the Contents sidebar shows in full. */
.toc-toggle {
  display: none;
}

.progress-track {
  height: 7px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 5px;
  transition: width .25s;
}

@media (max-width:920px) {
  .reader-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .reader-toc {
    position: static;
  }
}

/* ---------- Public / guest library ---------- */
.guest-top {
  position: relative;
  top: auto;
  z-index: 50;
  background: linear-gradient(90deg, var(--blue-dk), var(--blue));
  border-bottom: 3px solid var(--gold);
}

.guest-top-in {
  width: 94%;
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
}

.guest-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  flex: none;
  min-width: 0;
}

.guest-mark {
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  flex: none;
}

.guest-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.guest-brand-text {
  min-width: 0;
}

.guest-brand-name {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 19px;
  line-height: 1.15;
  color: #fff;
  white-space: nowrap;
}

.guest-brand-sub {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .16em;
  color: var(--blue-lt);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
}

.guest-hero {
  background: linear-gradient(135deg, var(--blue-dk) 0%, var(--blue) 100%);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  position: relative;
  overflow: hidden;
}

.guest-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(700px 260px at 85% -80px, rgba(217, 122, 69, .32), transparent 70%);
  pointer-events: none;
}

.guest-hero-in {
  width: 94%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 46px 22px 42px;
  position: relative;
  z-index: 1;
}

.guest-hero-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--gold-soft);
}

.guest-hero h1 {
  font-size: 37px;
  margin: 8px 0 8px;
  max-width: 660px;
  line-height: 1.15;
}

.guest-hero p {
  color: var(--blue-pale);
  max-width: 640px;
  margin: 0;
  font-size: 15.5px;
}

.guest-hero-search {
  max-width: 560px;
  margin-top: 22px;
}

.guest-hero-search svg {
  width: 18px;
  height: 18px;
}

.guest-hero-search input {
  padding: 13px 14px 13px 40px;
  font-size: 15px;
  border-radius: 11px;
}

.guest-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.guest-stats>div {
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 124px;
}

.guest-stats b {
  display: block;
  font-family: "Playfair Display", serif;
  font-size: 27px;
  line-height: 1.1;
}

.guest-stats span {
  font-size: 12px;
  color: var(--blue-pale);
}

.guest-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 600px;
  gap: 40px;
  align-items: start;
}

@media (max-width:1340px) {
  .guest-hero-grid {
    grid-template-columns: minmax(0, 1fr) 520px;
    gap: 32px;
  }
}

@media (max-width:1180px) {
  .guest-hero-grid {
    grid-template-columns: minmax(0, 1fr) 480px;
    gap: 28px;
  }

  .guest-stats>div {
    flex: 1 1 calc(50% - 7px);
  }
}

/* ---------- Hero announcements panel (guest view) ---------- */
.hero-ann-panel {
  background: var(--white);
  color: var(--text);
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(35, 92, 144, .30);
  overflow: hidden;
}

.hero-ann-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 13px;
  border-bottom: 3px solid var(--gold);
}

.hero-ann-head svg {
  width: 21px;
  height: 21px;
  color: var(--blue);
  flex: none;
}

.hero-ann-head h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--blue-dk);
}

.hero-ann-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 13px 20px;
  font: inherit;
  color: inherit;
}

.hero-ann-item:last-child {
  border-bottom: none;
}

.hero-ann-item:hover {
  background: var(--off);
}

.hero-ann-title {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--blue-dk);
  line-height: 1.35;
}

.hero-ann-meta {
  display: block;
  margin-top: 5px;
}

.ann-date-chip {
  display: inline-block;
  background: var(--gold-soft);
  color: var(--gold-ink);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 12px;
}

.hero-ann-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  white-space: normal;
  overflow: hidden;
}

.hero-ann-empty {
  padding: 18px 20px;
  font-size: 13.5px;
  color: var(--muted);
}

.hero-ann-foot {
  padding: 11px 20px 14px;
  border-top: 1px solid var(--border);
}

.hero-ann-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 2px 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue);
}

.hero-ann-all:hover {
  color: var(--blue-dk);
  text-decoration: underline;
}

.hero-ann-all svg {
  width: 14px;
  height: 14px;
}

@media (max-width:980px) {
  .guest-hero-grid {
    grid-template-columns: 1fr;
  }
}

.guest-main {
  width: 94%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 30px 22px 2px;
}

.guest-sec-head {
  margin-bottom: 10px;
}

.guest-sec-head h2 {
  font-size: 25px;
  margin: 0 0 3px;
}

.guest-sec-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.guest-foot {
  border-top: 1px solid var(--line);
  width: 94%;
  max-width: 1560px;
  margin: 16px auto 0;
  padding: 14px 22px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width:860px) {
  .guest-top-in {
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .guest-hero-in {
    padding: 34px 16px 32px;
  }

  .guest-hero h1 {
    font-size: 28px;
  }

  .guest-main {
    padding: 22px 14px 4px;
  }
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(18, 36, 54, .45);
  z-index: 55;
}

@media (max-width:1080px) {
  .grid-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .catalog-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .tree-panel {
    position: static;
  }
}

@media (max-width:860px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: none;
    box-shadow: var(--shadow);
  }

  /* Rounded right edge on the mobile drawer: the two right corners
           curve at 18px while the left corners stay square against the
           screen edge. overflow:hidden clips the blue gradient, brand
           stack and user block to those corners so no square blue corner
           pokes out; nav content keeps its inset padding and is untouched. */
  .sidebar {
    border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
    overflow: hidden;
  }

  /* Mobile drawer compaction: the whole side nav must fit the phone
           screen with NO internal scrolling, so the brand stack shrinks
           (seal 76px -> 48px, smaller title/subtitle, tighter padding),
           the user block slims down, and the nav rhythm tightens (rows
           stay >=36px tall for tapping). Desktop sidebar is untouched ΓÇö
           these rules live only inside this <=860px block. */
  .brand {
    padding: 10px 16px 6px;
  }

  .brand .mark {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
  }

  .brand h2 {
    font-size: 16px;
    letter-spacing: .1em;
    line-height: 1.15;
  }

  .brand .bsub {
    font-size: 12.5px;
    line-height: 1.25;
    margin-top: 0;
  }

  .side-user {
    padding: 8px 16px;
  }

  .side-user .su-name {
    line-height: 1.2;
  }

  .side-user .su-role {
    line-height: 1.3;
  }

  .nav {
    padding: 8px 12px 6px;
  }

  .nav-group {
    padding: 7px 10px 3px;
  }

  .nav-group:first-child {
    padding-top: 4px;
  }

  .nav-item {
    padding: 7.5px 11px;
    min-height: 36px;
    margin-bottom: 1px;
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: inline-flex;
  }

  .content {
    padding: 18px 14px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .topbar .global-search {
    display: none;
  }

  .grid-2,
  .form-grid,
  .spec-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .reader-page {
    padding: 34px 22px;
  }

  .topbar .t-title h1 {
    font-size: 18px;
  }

  /* The page title flexes into whatever room the bar leaves, so it
           ellipsizes instead of being crushed to zero width by the
           fixed-size buttons beside it. */
  .topbar .t-title {
    flex: 1 1 auto;
  }

  /* The search box is hidden at this width, so the spacer has nothing
           left to push apart ΓÇö but as a flex:1 item it still split the free
           width with the title and squeezed the breadcrumb into ellipsis.
           Drop it: the flexing title alone keeps the bell and buttons
           right-aligned, and the title gets the full remaining width. */
  .topbar .spacer {
    display: none;
  }

  /* Form controls at 16px stop iOS Safari's focus auto-zoom, whose
           scale jump otherwise shifts the whole layout mid-task. */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* Phone-width topbar: the Add Book / Log out buttons go icon-only
         (their labels live in .tb-label spans), the bar's gaps tighten,
         and the title keeps a readable share of the row. Applies to both
         roles ΓÇö a student bar is hamburger + title + bell + Log out. */
@media (max-width:700px) {
  .topbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .topbar .tb-label {
    display: none;
  }

  .topbar .btn {
    padding: 9px 11px;
  }

  .topbar .t-title .crumbs {
    font-size: 11px;
  }

  /* Phones drop the leading "ACTS Library ΓÇ║" crumb segment so the
           remaining section ΓÇ║ page fits whole ΓÇö no ellipsis ΓÇö beside the
           hamburger, bell and icon-only buttons. Desktop keeps the full
           breadcrumb; the bar stays one line tall, so sticky offsets are
           unchanged. The h1 eases to 17px for the longest titles
           (Registered Students) at 360ΓÇô390px. */
  .topbar .t-title .crumb-root {
    display: none;
  }

  .topbar .t-title h1 {
    font-size: 17px;
  }
}

/* Very narrow phones (~360px): the longest title ("Registered
         Students", ~165px of text at 17px) would outgrow the title box
         left by the fixed chrome, so the chrome tightens (padding, gaps,
         icon-button padding) and the title steps down once more. Measured
         at 390px the title box is 165px with the buttons ending at x=363;
         at 360px these savings return ~20px, giving a ~155px box for
         ~146px of 15px title text and ~124px of 10px breadcrumb ΓÇö both
         fit whole, still one line, bar height unchanged. */
@media (max-width:400px) {
  .topbar {
    gap: 6px;
    padding: 10px 8px;
  }

  .topbar .btn {
    padding: 9px 9px;
  }

  .topbar .t-title .crumbs {
    font-size: 10px;
  }

  .topbar .t-title h1 {
    font-size: 15px;
  }
}

@media (max-width:640px) {
  .panel-head {
    padding: 14px 16px;
  }

  .panel-body {
    padding: 16px;
  }

  .circ-foot {
    padding: 12px 16px 14px;
  }

  .modal-overlay {
    padding: 14px 10px;
  }

  .modal-head {
    padding: 16px 18px 0;
  }

  .modal-body {
    padding: 14px 18px 20px;
  }

  .modal-foot {
    padding: 0 18px 18px;
  }

  .detail-cover {
    height: 220px;
  }

  .kpi {
    padding: 15px;
  }

  .kpi .k-value {
    font-size: 30px;
  }

  .bar-sub {
    margin-left: 0;
  }

  .reader-page {
    padding: 28px 16px;
  }

  .book-cover {
    height: 210px;
  }

  /* "New in the library" strip only: full-width cards with a 210px
           cover were far too large on phones ΓÇö two compact columns
           instead, cover and type scaled down to match. The catalog
           grid keeps its full-width mobile cards. */
  .new-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .new-grid .book-cover {
    height: 160px;
    padding: 10px 8px 8px 16px;
  }

  .new-grid .book-cover .book {
    --book-w: 95px;
    --book-h: 118px;
    --depth: 15px;
    --lift: 8px;
  }

  .new-grid .book-cover .bc-fmt {
    top: 8px;
    right: 8px;
    font-size: 8.5px;
    padding: 2px 6px;
  }

  .new-grid .book-meta {
    padding: 9px 11px 11px;
    gap: 4px;
  }

  .new-grid .book-meta .bm-title {
    font-size: 12.5px;
  }

  .new-grid .book-meta .bm-author {
    font-size: 11px;
  }

  .new-grid .book-meta .bm-foot {
    flex-wrap: wrap;
    gap: 5px;
  }

  .guest-brand-sub {
    white-space: normal;
  }
}

@media (max-width:860px) {
  .guest-brand-sub {
    font-size: 9px;
    letter-spacing: .13em;
  }
}

@media (max-width:640px) {
  .guest-brand {
    flex: 1 1 auto;
    gap: 10px;
  }

  .guest-mark {
    width: 40px;
    height: 40px;
  }

  .guest-brand-name {
    font-size: 16px;
  }

  .guest-brand-sub {
    font-size: 8px;
    letter-spacing: .1em;
  }

  #loginScreen {
    padding: 24px 12px 22px;
  }

  .login-body {
    padding: 18px 16px 16px;
  }

  .login-card-head {
    padding: 18px 16px 16px;
  }

  .login-lockup-name {
    font-size: 14.5px;
  }
}

/* ---------- Mobile: compact login toast + reader view (Γëñ860px) ----------
         JOB 1: the Login successful toast dominated the phone screen;
         it shrinks to a compact card here. (The Log out confirmation
         needs no phone rules ΓÇö its base card is already min(92vw, 360px).)
         JOB 2: the reader trades its desktop left Contents column for a
         collapsible Contents bar above a full-width page, with the reading
         controls in a sticky bottom bar. Desktop is untouched ΓÇö every rule
         lives inside this Γëñ860px block (plus the display:none .toc-toggle
         base rule above). */
@media (max-width:860px) {

  /* Login successful toast: clearly smaller, bottom-right */
  #toastRoot {
    left: auto;
    right: 12px;
    bottom: 12px;
    width: min(78vw, 300px);
    max-width: none;
  }

  .login-toast {
    padding: 13px 36px 12px 13px;
    border-radius: 12px;
  }

  .lt-badge {
    width: 28px;
    height: 28px;
  }

  .lt-badge svg {
    width: 14px;
    height: 14px;
  }

  .lt-title {
    font-size: 15px;
  }

  .lt-welcome {
    font-size: 13px;
  }

  .lt-divider {
    margin: 10px 0 9px 39px;
  }

  .lt-details {
    margin-left: 39px;
    gap: 8px 12px;
  }

  .lt-field .lt-k {
    font-size: 10px;
  }

  .lt-field .lt-v {
    font-size: 12.5px;
  }

  /* Reader: Contents becomes a collapsible bar above the page */
  .reader-toc {
    padding: 0;
    overflow: hidden;
  }

  .toc-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  .toc-toggle .tt-ic {
    display: flex;
    color: var(--blue-dk);
    flex: none;
  }

  .toc-toggle .tt-ic svg {
    width: 18px;
    height: 18px;
  }

  .toc-toggle .tt-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    flex: none;
  }

  .toc-toggle .tt-cur {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
  }

  .toc-toggle .tt-chev {
    display: flex;
    color: var(--muted);
    flex: none;
    transition: transform .18s;
  }

  .toc-toggle .tt-chev svg {
    width: 16px;
    height: 16px;
  }

  .reader-toc.open .tt-chev {
    transform: rotate(180deg);
  }

  .reader-toc .toc-list {
    display: none;
  }

  .reader-toc.open .toc-list {
    display: block;
    border-top: 1px solid var(--line);
    padding: 10px 12px 12px;
    max-height: 46vh;
    overflow-y: auto;
  }

  /* Reader: compact two-row header, full-width page. Row 1 is
           just the Back button (left) and the Page chip (right) ΓÇö the
           little cover thumbnail is hidden on mobile: at phone size it
           rendered as an awkward cropped sliver between them. Row 2 is
           the title/author, full width. Desktop keeps its thumbnail. */
  .reader-head {
    gap: 6px 10px;
    margin-bottom: 10px;
  }

  .reader-head .btn {
    padding: 8px 12px;
  }

  .reader-head-thumb {
    display: none;
  }

  .reader-head-meta {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
  }

  .reader-head .badge {
    margin-left: auto;
  }

  .reader-head-title {
    font-size: 17px;
    line-height: 1.3;
  }

  .reader-head-meta .small {
    font-size: 12.5px;
  }

  .reader-page {
    padding: 30px 20px;
  }

  /* Reader: sticky bottom control bar ΓÇö Previous / % read / Next on
           the first row, page jump + font size on the second row. */
  .reader-tools {
    position: sticky;
    bottom: 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 16px rgba(35, 92, 144, .08);
    margin: 14px -14px -18px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    row-gap: 8px;
    column-gap: 10px;
    justify-content: space-between;
  }

  .reader-tools .btn {
    padding: 8px 12px;
  }

  .reader-tools .rt-prev {
    order: 1;
  }

  .reader-tools .rt-pct {
    order: 2;
  }

  .reader-tools .rt-next {
    order: 3;
  }

  .reader-tools .reader-jump {
    order: 4;
    flex: 1 1 auto;
    min-width: 0;
  }

  .reader-tools .reader-font {
    order: 5;
  }
}

/* ---------- Mobile: dashboard stat cards in a 2├ù2 grid (Γëñ860px) ----------
         The .kpi-row stat-card grid (student dashboard's 4 cards, and the
         admin dashboard's KPI cards which share the same grid) switches
         from auto-fit ΓÇö which at phone width fits only one minmax(180px)
         column and stacks the cards one per row ΓÇö to two equal columns,
         two cards per row. Placed after the Γëñ640px .kpi rules above so
         its compact padding / sizes win at every phone width. Desktop is
         untouched: every rule lives inside this Γëñ860px block. */
@media (max-width:860px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
  }

  .kpi {
    padding: 12px;
    min-width: 0;
  }

  .kpi .k-label {
    flex-wrap: wrap;
    row-gap: 2px;
    line-height: 1.3;
  }

  .kpi .k-value {
    font-size: 26px;
    line-height: 1.1;
    margin-top: 5px;
  }

  .kpi .k-sub {
    font-size: 11.5px;
    line-height: 1.4;
    overflow-wrap: break-word;
  }
}

/* ---------- Mobile: catalog book grid fits the phone (Γëñ860px) ----------
         The shared catalog results (student Browse Books AND the guest
         Library Catalog ΓÇö both render through #catalogResults) switch
         from one very large card per row to two compact cards per row.
         Scoped to #catalogResults so the dashboard "New in the library"
         strip (.new-grid) and Listed Books keep their own layouts, and
         the desktop catalog grid is untouched. Card text is sized for
         the ~150ΓÇô175px phone card: meta title clamps to two lines,
         author ┬╖ year stays on one line, and the footer badge + views
         shrink to fit on a single line. Typographic covers scale their
         inside type down with the box; photo covers (.cover-img) keep
         their full-bleed fill and only get shorter. */
@media (max-width:860px) {
  #catalogResults .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  #catalogResults .book-card {
    min-width: 0;
  }

  #catalogResults .book-cover {
    height: 190px;
    padding: 14px 10px 10px 18px;
  }

  #catalogResults .book-cover .book {
    --book-w: 112px;
    --book-h: 140px;
    --depth: 18px;
    --lift: 9.5px;
  }

  #catalogResults .book-cover .bc-fmt {
    top: 9px;
    right: 9px;
    font-size: 9px;
    padding: 2px 7px;
    letter-spacing: .06em;
  }

  #catalogResults .book-meta {
    padding: 10px 11px 12px;
    gap: 4px;
  }

  #catalogResults .book-meta .bm-title {
    font-size: 13.5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  #catalogResults .book-meta .bm-author {
    font-size: 11.5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #catalogResults .book-meta .bm-foot {
    padding-top: 6px;
    flex-wrap: nowrap;
    gap: 6px;
  }

  #catalogResults .book-meta .bm-foot .badge {
    font-size: 10.5px;
    padding: 2px 7px;
    gap: 4px;
  }

  #catalogResults .book-meta .bm-foot .small {
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* List view: one row per book, kept compact ΓÇö small thumbnail,
           wrapping text, shrunken status badge so nothing overflows. */
  #catalogResults .book-row {
    padding: 11px 12px;
    gap: 11px;
  }

  #catalogResults .book-row .thumb-cover {
    width: 40px;
    height: 54px;
    font-size: 15px;
  }

  #catalogResults .book-row .br-title {
    font-size: 14px;
    line-height: 1.3;
  }

  #catalogResults .book-row .br-sub {
    font-size: 11.5px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  #catalogResults .book-row .badge {
    font-size: 10.5px;
    padding: 2px 7px;
    white-space: nowrap;
  }
}

/* True phone widths: the cover box shortens to match the ~150ΓÇô175px
         card, and the typographic cover's inside type steps down once
         more so long titles/authors stay inside the cover. */
@media (max-width:640px) {
  #catalogResults .book-cover {
    height: 160px;
    padding: 10px 8px 8px 16px;
  }

  #catalogResults .book-cover .book {
    --book-w: 95px;
    --book-h: 118px;
    --depth: 15px;
    --lift: 8px;
  }

  .book .spine {
    padding-top: 10px;
  }

  .book .spine span {
    font-size: 7.5px;
    max-height: calc(100% - 36px);
  }

  #catalogResults .book-cover .bc-fmt {
    top: 8px;
    right: 8px;
    font-size: 8.5px;
    padding: 2px 6px;
  }

  /* Narrowest cards (~149ΓÇô160px on 360px phones, guest view
           included): the footer badge + views tighten once more so the
           longest combo ("8 of 8 available" + a 3-digit view count)
           still fits on its single line. */
  #catalogResults .book-meta {
    padding: 9px 10px 11px;
  }

  #catalogResults .book-meta .bm-foot {
    gap: 4px;
  }

  #catalogResults .book-meta .bm-foot .badge {
    font-size: 10px;
    padding: 2px 5px;
  }

  #catalogResults .book-meta .bm-foot .small {
    font-size: 11px;
  }

  #catalogResults .book-meta .bm-foot svg {
    width: 12px !important;
    height: 12px !important;
  }
}

/* ---------- Mobile refinement pass (analysis-driven, Γëñ860px) ----------
         A whole-system review at phone width found the remaining friction
         was vertical economy and row rhythm, not breakage: the guest hero
         pushed the catalog far down the page, the Categories tree sat as a
         long list above the books, the catalog toolbar stacked into 4ΓÇô5
         rows, Listed Books still used the old one-huge-card-per-row grid,
         and panel-head search boxes squeezed beside their buttons. Every
         rule below lives inside phone media blocks (or hides a control
         that only exists on phones); the desktop layout is untouched. */

/* Categories tree: the panel head gains a current-selection label
         and a chevron toggle that are desktop-hidden (desktop keeps the
         full tree always visible, exactly as approved). */
.tree-toggle {
  display: none;
}

.tree-current {
  display: none;
}

@media (max-width:860px) {

  /* --- Guest hero: tighter stack so the catalog starts sooner --- */
  .guest-hero-in {
    padding: 26px 16px 26px;
  }

  .guest-hero p {
    font-size: 14.5px;
  }

  .guest-hero-search {
    margin-top: 16px;
  }

  .guest-stats {
    gap: 10px;
    margin-top: 18px;
  }

  .guest-stats>div {
    padding: 10px 14px;
    border-radius: 10px;
  }

  .guest-stats b {
    font-size: 23px;
  }

  .guest-hero-main .btn {
    flex: 1 1 0;
    justify-content: center;
  }

  /* Hero announcements: same panel, denser rows, 2-line excerpts */
  .hero-ann-head {
    padding: 13px 16px 10px;
  }

  .hero-ann-head h3 {
    font-size: 17px;
  }

  .hero-ann-item {
    padding: 11px 16px;
  }

  .hero-ann-excerpt {
    -webkit-line-clamp: 2;
  }

  .hero-ann-foot {
    padding: 9px 16px 12px;
  }

  /* --- Categories tree collapses to one compact bar on phones:
           the books start right under the toolbar instead of after a
           ~350px list; tapping the bar opens the full tree. --- */
  .tree-head {
    flex-wrap: nowrap;
  }

  .tree-current {
    display: block;
    flex: 1;
    min-width: 0;
    text-align: right;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid var(--line2);
    background: var(--surface);
    border-radius: 8px;
    color: var(--ink2);
    cursor: pointer;
  }

  .tree-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform .18s;
  }

  .tree-panel .tree-list {
    display: none;
  }

  .tree-panel.open .tree-list {
    display: block;
  }

  .tree-panel.open .tree-toggle svg {
    transform: rotate(180deg);
  }

  /* --- Catalog toolbar: search on its own row; the format pills
           get their OWN full-width row, flush with the content's left
           padding (justify-content:flex-start, no squeezing beside
           other controls ΓÇö sharing a row with "Available only" and the
           Sort select squeezed the strip and cut the active "All
           formats" pill off at the left edge); "Available only", the
           Sort select and the grid/list toggle share the last row. --- */
  .catalog-layout>div>.pill-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .catalog-layout>div>.pill-row::-webkit-scrollbar {
    display: none;
  }

  .catalog-layout>div>.pill-row .pill {
    flex: none;
  }

  .catalog-toolbar {
    gap: 8px;
    margin-bottom: 14px;
  }

  .catalog-toolbar .grow {
    flex: 1 1 100%;
    min-width: 0;
  }

  .catalog-toolbar .pill-row {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .catalog-toolbar .pill-row::-webkit-scrollbar {
    display: none;
  }

  .catalog-toolbar .pill-row .pill {
    flex: none;
  }

  .catalog-toolbar>.pill {
    flex: none;
  }

  .catalog-toolbar select {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
  }

  .catalog-toolbar .view-toggle {
    flex: none;
  }

  .catalog-toolbar .view-toggle button {
    padding: 10px 12px;
  }

  .pill {
    padding: 9px 15px;
  }

  /* --- Listed Books: same compact two-per-row cards the catalog
           got (its grid was outside the #catalogResults scope) --- */
  .saved-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .saved-grid .book-card {
    min-width: 0;
  }

  .saved-grid .book-cover {
    height: 190px;
    padding: 14px 10px 10px 18px;
  }

  .saved-grid .book-cover .book {
    --book-w: 112px;
    --book-h: 140px;
    --depth: 18px;
    --lift: 9.5px;
  }

  .saved-grid .book-cover .bc-fmt {
    top: 9px;
    right: 9px;
    font-size: 9px;
    padding: 2px 7px;
    letter-spacing: .06em;
  }

  .saved-grid .book-meta {
    padding: 10px 11px 12px;
    gap: 4px;
  }

  .saved-grid .book-meta .bm-title {
    font-size: 13.5px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .saved-grid .book-meta .bm-author {
    font-size: 11.5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .saved-grid .book-meta .bm-foot {
    padding-top: 6px;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .saved-grid .book-meta .bm-foot .badge {
    font-size: 10.5px;
    padding: 2px 7px;
    gap: 4px;
  }

  .saved-grid .book-meta .bm-foot .small {
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* --- KPI rows: an odd last card (admin's 5th, Issued's 3rd)
           spans the row instead of sitting half-width --- */
  .kpi-row>*:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* --- Tap targets: shell icon buttons and pager reach 40px --- */
  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .pg-btn {
    min-height: 40px;
  }

  /* --- Book detail modal: the spec list stays two columns on
           phones (values are short) instead of six stacked rows --- */
  .modal .spec-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 14px;
  }

  /* --- Login card: slightly denser so it sits comfortably on
           short phones without awkward scrolling --- */
  #loginScreen {
    padding: 20px 12px;
  }

  .login-seal {
    width: 40px;
    height: 40px;
  }

  .login-tagline {
    margin-top: 9px;
    font-size: 12px;
  }

  .login-row {
    margin-bottom: 13px;
  }

  .login-signin {
    padding: 11px 16px;
  }

  .login-or {
    margin: 12px 0;
  }

  .login-under {
    margin-top: 12px;
  }
}

@media (max-width:640px) {
  .guest-hero h1 {
    font-size: 25px;
    line-height: 1.18;
  }

  .guest-hero-kicker {
    font-size: 11px;
  }

  .guest-sec-head h2 {
    font-size: 22px;
  }

  .saved-grid .book-cover {
    height: 154px;
    padding: 12px 12px 11px 20px;
  }

  .saved-grid .book-cover .bc-cat {
    font-size: 8.5px;
    letter-spacing: .12em;
  }

  .saved-grid .book-cover .bc-title {
    font-size: 14px;
  }

  .saved-grid .book-cover .bc-author {
    font-size: 10.5px;
  }

  .saved-grid .book-cover .bc-fmt {
    top: 8px;
    right: 8px;
    font-size: 8.5px;
    padding: 2px 6px;
  }

  .saved-grid .book-meta {
    padding: 9px 10px 11px;
  }

  .saved-grid .book-meta .bm-foot {
    gap: 4px;
  }

  .saved-grid .book-meta .bm-foot .badge {
    font-size: 10px;
    padding: 2px 5px;
  }

  .saved-grid .book-meta .bm-foot .small {
    font-size: 11px;
  }

  .saved-grid .book-meta .bm-foot svg {
    width: 12px !important;
    height: 12px !important;
  }

  /* Student welcome banner: shorter on phones, its two actions
           share the row as equal thumb targets (inline styles on this
           one panel are overridden deliberately, phones only) */
  .panel[style*="linear-gradient"] .panel-body {
    padding: 18px !important;
  }

  .panel[style*="linear-gradient"] h2 {
    font-size: 23px !important;
  }

  .panel[style*="linear-gradient"] .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Announcement cards: slightly tighter rhythm */
  .ann-card {
    padding: 13px 14px;
  }

  /* Panel heads (admin tables, circulation): the search box takes
           its own full-width row instead of squeezing beside the title
           and buttons; the action button stays on the first row */
  .panel-head .search-box {
    width: 100% !important;
    flex: 1 1 100%;
    order: 5;
  }

  .mini-btn {
    padding: 7px 10px;
  }

  /* Book detail modal: shorter cover banner, bigger action taps */
  .detail-cover {
    min-height: 220px;
    padding: 20px 16px 16px 26px;
  }

  .detail-cover .book.book-detail-view {
    --book-w: 140px;
    --book-h: 173px;
    --depth: 22px;
    --lift: 11.7px;
  }

  .modal-body>div:last-child .btn {
    flex: 1 1 40%;
    justify-content: center;
    min-height: 42px;
  }

  /* Form modals: Cancel / Save share the footer as equal halves */
  .modal form .modal-foot .btn {
    flex: 1;
    justify-content: center;
  }

  /* Profile / Settings / announcement forms: submit spans the
           card so it is reachable without precision tapping */
  form[data-form="changePw"] .btn,
  form[data-form="postAnn"] .btn {
    width: 100%;
    justify-content: center;
  }

  /* Book Report: the category filter spans its row */
  .panel-body .field[style] {
    min-width: 0 !important;
  }

  /* Category bars: slightly narrower label column */
  .bar-row {
    grid-template-columns: 100px minmax(0, 1fr) 34px;
  }

  .bar-sub {
    margin-left: 110px;
  }

  /* Reader body text: left-aligned on phones (justified text
           leaves stretched word gaps in a narrow column) */
  .reader-page p {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}



/* Desktop 15-book catalog grid (5 columns x 3 rows fit in view) */
@media (min-width:1024px) {
  #catalogResults .book-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
  }

  #catalogResults .book-cover {
    height: 156px;
    padding: 12px 10px 10px 16px;
  }

  #catalogResults .book-cover .book {
    --book-w: 96px;
    --book-h: 120px;
    --depth: 16px;
    --lift: 8.5px;
    filter: drop-shadow(10px 14px 10px rgba(25, 40, 58, .30));
  }

  #catalogResults .book .spine span {
    font-size: 7px;
    max-height: calc(100% - 32px);
  }

  #catalogResults .book .spine::after {
    bottom: 16px;
    height: 4px;
  }

  #catalogResults .book-cover .bc-fmt {
    top: 8px;
    right: 8px;
    font-size: 8.5px;
    padding: 2px 6px;
  }

  #catalogResults .book-meta {
    padding: 8px 10px 10px;
    gap: 3px;
  }

  #catalogResults .book-meta .bm-title {
    font-size: 12px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 30px;
  }

  #catalogResults .book-meta .bm-author {
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #catalogResults .book-meta .bm-foot {
    padding-top: 4px;
    gap: 4px;
  }

  #catalogResults .book-meta .bm-foot .badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  #catalogResults .book-meta .bm-foot .small {
    font-size: 10.5px;
  }
}