.app-nav[hidden] {
  display: none;
}
.app-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 25px;
  min-height: 76px;
  padding: 14px 28px;
  background: #fff;
  color: #182c60;
  font:
    600 15px/1.4 Arial,
    sans-serif;
  box-sizing: border-box;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 21px;
  text-decoration: none;
  color: #183b98;
}
.app-menus {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.app-menus details {
  position: relative;
}
.app-menus summary {
  cursor: pointer;
  padding: 12px;
  border-radius: 10px;
  list-style: none;
  white-space: nowrap;
}
.app-menus summary::after {
  content: '⌄';
  margin-left: 9px;
  color: #33476a;
}
.app-menus details[open] > summary,
.app-menus summary:hover {
  background: #edf2ff;
  color: #3455ef;
}
.app-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 265px;
  max-height: 70vh;
  overflow: auto;
  padding: 10px;
  background: white;
  border: 1px solid #dbe3f3;
  box-shadow: 0 16px 36px #1c34752b;
  border-radius: 14px;
  z-index: 60;
}
.app-dropdown > a,
.nav-soon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #253b6c;
}
.app-dropdown > a:hover {
  background: #edf2ff;
}
.nav-soon {
  color: #33476a;
  cursor: default;
}
.nav-soon small {
  font-size: 10px;
  letter-spacing: 0.2px;
  color: #33476a;
  background: #f0f3fa;
  padding: 3px 6px;
  white-space: nowrap;
}
.nav-section,
.nav-library-picker > label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #33476a;
  margin: 12px 10px 5px;
}
.nav-library-picker {
  border-top: 1px solid #e6ebf5;
  border-bottom: 1px solid #e6ebf5;
  padding-bottom: 10px;
}
.nav-library-picker select {
  width: 100%;
  font-size: 13px;
  margin: 5px 0;
}
.nav-library-picker button {
  font-size: 12px;
  margin: 2px 0;
}
.nav-account {
  font-size: 13px;
  color: #3455ef;
  text-decoration: none;
  white-space: nowrap;
}
.has-app-nav > .sidebar {
  top: 76px;
}
.has-app-nav > .sidebar > .brand,
.has-app-nav > .sidebar > .library-label,
.has-app-nav > .sidebar > a[href='/community.html'],
.has-app-nav > .sidebar > a[href='/account.html'] {
  display: none;
}
.has-app-nav > .public-nav {
  display: none;
}
.has-app-nav.public-page > main {
  margin-top: 30px;
}
.local-library-page {
  max-width: 1080px !important;
}
.local-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  margin: 24px 0;
}
.local-library-card,
.local-editor {
  background: #fff;
  border: 1px solid #dce4f5;
  border-radius: 20px;
  padding: 26px;
}
.local-library-card h2 {
  font-size: 25px;
}
.local-library-card dl {
  display: grid;
  grid-template-columns: 95px 1fr;
  gap: 10px;
  font-size: 14px;
}
.local-library-card dt {
  color: #33476a;
}
.local-library-card dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.local-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.local-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.local-fields label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.local-fields .full {
  grid-column: 1/-1;
}
.local-fields small {
  font-size: 12px;
  color: #33476a;
}
.local-library-card [data-secret] {
  margin-top: 15px;
}
.danger {
  color: #a5293c !important;
}
.has-app-nav .stats {
  scroll-margin-top: 100px;
}
@media (max-width: 900px) {
  .app-nav {
    gap: 8px;
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .app-brand {
    flex: 1;
  }
  .app-menus {
    order: 3;
    flex-basis: 100%;
    justify-content: space-between;
    gap: 0;
  }
  .app-menus summary {
    font-size: 13px;
    padding: 10px 6px;
  }
  .app-menus summary::after {
    margin-left: 5px;
  }
  .app-menus details:nth-child(n + 3) .app-dropdown {
    left: auto;
    right: 0;
  }
  .has-app-nav > .sidebar {
    top: 120px;
  }
}
@media (max-width: 750px) {
  .has-app-nav > .sidebar {
    top: auto;
    position: relative;
  }
  .app-nav {
    position: sticky;
    top: 0;
  }
  .app-dropdown {
    width: min(265px, 80vw);
    max-height: 65vh;
  }
  .local-fields {
    grid-template-columns: 1fr;
  }
  .local-fields .full {
    grid-column: auto;
  }
  .local-library-card,
  .local-editor {
    padding: 20px;
  }
  .local-library-card dl {
    grid-template-columns: 85px 1fr;
  }
  .has-app-nav.public-page > main {
    margin-top: 20px;
  }
  .nav-account {
    font-size: 12px;
  }
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 18px 0;
  border-bottom: 1px solid #dce4f5;
  margin-bottom: 18px;
}
.book-actions small {
  flex-basis: 100%;
  color: #33476a;
  font-size: 12px;
}
.book-actions button {
  font-size: 13px;
  padding: 8px 12px;
}

.loan-record-editor {
  grid-column: 1/-1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border: 1px solid #dce4f5;
  border-radius: 12px;
  padding: 20px;
}
.loan-record-editor legend {
  font-weight: 700;
  color: #203e93;
  padding: 0 8px;
}
.loan-record-editor .wide {
  grid-column: 1/-1;
}
@media (max-width: 650px) {
  .loan-record-editor {
    grid-template-columns: 1fr;
  }
}

.borrowed-overview {
  margin: 28px 0;
  scroll-margin-top: 95px;
}
.borrowed-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}
.borrowed-card {
  background: white;
  border: 1px solid #dce4f5;
  border-radius: 16px;
  padding: 22px;
}
.borrowed-card h3 {
  font-size: 22px;
  margin: 10px 0;
}
.borrowed-card dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  font-size: 14px;
}
.borrowed-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.borrowed-card dt {
  color: #33476a;
}

.has-app-nav [hidden] {
  display: none !important;
}
.app-menus details {
  margin: 0;
  padding: 0;
  border: 0;
}
.app-nav {
  height: 76px;
}
@media (max-width: 900px) {
  .app-nav {
    height: auto;
  }
}

.local-fields input,
.local-fields textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ccd7ed;
  border-radius: 9px;
  background: #fff;
  color: #20335e;
  font: inherit;
  line-height: 1.5;
}
.local-fields input:focus,
.local-fields textarea:focus {
  outline: 2px solid #7e98ff;
  outline-offset: 2px;
}
.local-library-card [data-secret] input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px;
  border: 1px solid #ccd7ed;
  border-radius: 8px;
  font: inherit;
}

#nav-phone-tools > button,
#nav-library-tools > button,
#nav-app-tools > button,
#nav-library-tools > a,
#nav-app-tools > a {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #253b6c;
  text-align: left;
  font: inherit;
  text-decoration: none;
}
#nav-phone-tools > button:hover,
#nav-library-tools > button:hover,
#nav-app-tools > button:hover,
#nav-library-tools > a:hover,
#nav-app-tools > a:hover {
  background: #edf2ff;
}

.has-app-nav #mobile-refresh,
.has-app-nav #mobile-export {
  display: none;
}

.nav-event-sublist {
  padding-left: 10px;
  border-left: 3px solid #3455ef;
  margin-left: 10px;
}

/* Keep navigation visible at every viewport size, including installed web apps. */
.app-nav {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 100;
}
@media (max-width: 750px) {
  .app-menus {
    flex-wrap: wrap;
  }
  .app-menus > details {
    flex: 0 0 33.333%;
    min-width: 0;
  }
  .app-menus summary {
    text-align: center;
    white-space: normal;
  }
  .app-dropdown {
    position: fixed;
    top: var(--app-nav-height, 180px);
    left: 12px !important;
    right: 12px !important;
    width: auto;
    max-height: calc(100dvh - var(--app-nav-height, 180px) - 20px);
  }
}

.nav-event-sublist > a {
  display: block;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #253b6c;
}
.nav-event-sublist > a:hover,
.nav-event-sublist > a:focus-visible {
  background: #edf2ff;
  color: #2443bf;
}

.app-menu-toggle,
.compact-account {
  display: none;
}
.app-nav:not(.nav-compact) {
  flex-wrap: nowrap;
}
.app-nav:not(.nav-compact) .app-menus {
  flex-wrap: nowrap;
  flex-basis: auto;
  order: initial;
  gap: 8px;
}
.app-nav:not(.nav-compact) .app-menus > details {
  flex: initial;
}
.app-nav:not(.nav-compact) summary {
  white-space: nowrap;
}
.app-nav.nav-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  height: auto;
  min-height: 64px;
  max-height: 100dvh;
  overflow-y: auto;
  padding: 10px 16px;
}
.nav-compact .app-brand {
  flex: 1;
  min-width: 0;
  font-size: 20px;
}
.nav-compact .app-menu-toggle {
  display: block;
  flex: none;
}
.nav-compact > .nav-account {
  display: none;
}
.nav-compact .app-menus {
  display: none;
  order: 3;
  flex: 0 0 100%;
  padding-top: 8px;
}
.nav-compact.menu-expanded .app-menus {
  display: block;
}
.nav-compact .app-menus > details {
  display: block;
  width: 100%;
  border-bottom: 1px solid #dbe3f3;
}
.nav-compact .app-menus summary {
  text-align: left;
  min-height: 44px;
  padding: 12px;
  white-space: normal;
}
.nav-compact .app-dropdown {
  position: static !important;
  inset: auto !important;
  width: 100%;
  max-height: none;
  overflow: visible;
  box-shadow: none;
  border: 0;
  border-radius: 0;
  padding: 0 10px 10px;
}
.nav-compact .compact-account {
  display: block;
  padding: 14px 12px;
  color: #2443bf;
  text-decoration: none;
}
.nav-compact .app-menus details[open] > summary {
  background: #edf2ff;
}

.app-nav .nav-account {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  min-height: 44px;
  border-radius: 50%;
  color: #2443bf;
  background: #edf2ff;
}
.app-nav.nav-compact > .nav-account {
  display: flex;
  order: 2;
}
.nav-account:hover,
.nav-account:focus-visible {
  background: #dbe5ff;
}
@media (max-width: 360px) {
  .nav-compact .app-brand span {
    display: none;
  }
}

.nav-help,
.context-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: #3455ef;
  color: #fff !important;
  font:
    700 20px Arial,
    sans-serif;
  text-decoration: none;
}
.app-nav .nav-help {
  min-width: 44px;
  min-height: 44px;
}
.nav-compact .nav-help {
  order: 2;
}
.context-help {
  vertical-align: middle;
  margin-left: 8px;
}
.help-topic {
  scroll-margin-top: 110px;
}
.help-rating [aria-pressed='true'] {
  outline: 3px solid #102039;
  outline-offset: 2px;
}

/* Keep Help readable beside the account icon in both header layouts. */
.app-nav .nav-help {
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  font:
    600 14px/1.4 Arial,
    sans-serif;
}

.app-nav .nav-logout {
  white-space: nowrap;
  padding: 10px 12px;
  align-self: center;
  font-size: 14px;
}

/* Thin header: the logo sets the bar height (44px, the same as the tap targets beside it). */
.app-nav,
.app-nav.nav-compact {
  height: auto;
  min-height: 0;
  padding-top: 4px;
  padding-bottom: 4px;
}
.app-brand img {
  width: auto;
  height: 44px;
}
.nav-compact .app-brand {
  flex: none;
  margin-right: auto;
}
@media (min-width: 751px) {
  .has-app-nav > .sidebar {
    top: var(--app-nav-height, 52px);
  }
}
/* Menu icon: three drawn bars; Log out sits at the end of the menus (bottom of the open phone menu, far right on wide screens). */
.menu-bars {
  display: inline-block;
  vertical-align: middle;
  width: 26px;
  height: 20px;
  background:
    linear-gradient(currentColor 0 0) top/100% 3px no-repeat,
    linear-gradient(currentColor 0 0) center/100% 3px no-repeat,
    linear-gradient(currentColor 0 0) bottom/100% 3px no-repeat;
  border-radius: 1px;
}
.app-nav.nav-compact .app-menu-toggle {
  display: inline-flex;
  align-items: center;
}
/* Log off sits in the header beside My account, as in the prototype. */
.app-nav > .nav-logout {
  order: 2;
  flex: none;
  padding: 10px 4px;
  color: #2443bf;
  text-decoration: underline;
}
/* Pages without the library footer get Help and More (in progress) at the bottom. */
.app-more-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 32px auto 0;
  padding: 24px 16px;
  max-width: 1120px;
  border-top: 1px solid #dbe3f3;
}

/* Beta menu bar on screens wider than 900px, styled as on the prototype: the three menus centred in the bar.
   Fallbacks keep it right on pages that don't load tokens.css yet. */
.app-nav:not(.nav-compact) .app-menus {
  flex: 0 1 auto;
  margin: 0 auto;
  gap: 4px;
  font-family: var(--bm-font, inherit);
}
.app-nav:not(.nav-compact) .app-menus > details > summary {
  padding: 10px 7px;
  border-radius: var(--bm-radius-control, 8px);
  color: var(--bm-teal-dark, #244750);
  font-size: 17px;
  font-weight: 700;
}
.app-nav:not(.nav-compact) .app-menus > details[open] > summary,
.app-nav:not(.nav-compact) .app-menus > details > summary:hover,
.app-nav:not(.nav-compact) .app-menus > details > summary[aria-current='true'] {
  background: var(--bm-surface-warm, #f3f1eb);
  color: var(--bm-teal-dark, #244750);
}
.app-nav:not(.nav-compact) .app-dropdown a {
  color: var(--bm-teal-dark, #244750);
  font-size: 16px;
  font-weight: 400;
}
/* My Library: the words are a plain link to the library; it has no menu for beta. */
.app-menu-split {
  position: relative;
}
.app-menu-home {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.app-menu-home:hover {
  text-decoration: underline;
}
.app-nav:not(.nav-compact) .app-menu-split {
  display: flex;
  align-items: center;
  border-radius: var(--bm-radius-control, 8px);
}
.app-nav:not(.nav-compact) .app-menu-home {
  padding: 10px 7px;
  color: var(--bm-teal-dark, #244750);
  font-size: 17px;
  font-weight: 700;
}
.app-nav:not(.nav-compact) .app-menu-split:is(:hover, :has(> a[aria-current='page'])) {
  background: var(--bm-surface-warm, #f3f1eb);
}
/* Behind ≡: one row. */
.nav-compact .app-menus > .app-menu-split {
  border-bottom: 1px solid #dbe3f3;
}
.nav-compact .app-menu-home {
  display: block;
  box-sizing: border-box;
  min-height: 44px;
  padding: 12px;
}
/* The current page's menu has a teal line under its tab, as on the prototype. */
.app-nav:not(.nav-compact) .app-menus > details > summary[aria-current='true'],
.app-nav:not(.nav-compact) .app-menu-split:has(> a[aria-current='page']) {
  border-radius: var(--bm-radius-control, 8px) var(--bm-radius-control, 8px) 0 0;
  box-shadow: inset 0 -3px 0 var(--bm-teal, #006072);
}
