/* Shared readable text and control states across every BookMaestro page. */
:root {
  --muted: #33476a;
  --ink: #172f55;
}
body {
  color: #172f55;
}
.muted,
.meta,
.fine,
.label,
.breadcrumb,
.nav-soon,
.nav-soon small,
.nav-section,
.nav-library-picker > label,
.local-library-card dt,
.local-fields small,
.book-actions small,
.borrowed-card dt,
.stats span,
.stats small,
.public-footer,
footer {
  color: #33476a !important;
  opacity: 1 !important;
}
input::placeholder,
textarea::placeholder {
  color: #445779;
  opacity: 1;
}
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled='true'] {
  opacity: 1 !important;
  color: #33476a !important;
  background-color: #e3e9f5 !important;
  border-color: #7a8aa6 !important;
  cursor: not-allowed;
}
button:disabled *,
[aria-disabled='true'] * {
  color: inherit !important;
  opacity: 1 !important;
}
.privacy-note {
  opacity: 1;
}
.rating-star {
  color: #52627f;
}
.rating-star.full {
  color: #805700;
}
.rating-star.half {
  background: linear-gradient(90deg, #2949d5 50%, #52627f 50%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.cover {
  color: #fff;
  background: #243b64;
}
.cover small,
.cover-title {
  color: #fff !important;
  opacity: 1 !important;
}
.community-hero .eyebrow {
  color: #ffe27a;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #234fc4;
  outline-offset: 3px;
}
.badge {
  color: #33476a !important;
}

/* Visible dismissal remains at the top of every scrolling app dialog. */
dialog[data-visible-close] > .popup-close-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  height: 0;
  overflow: visible;
}
dialog .popup-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #33476a;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}
dialog .popup-close-button:hover {
  background: #f0f0f0;
}
dialog .popup-close-button:focus-visible {
  outline: 3px solid #e39100;
  outline-offset: 3px;
}
dialog[data-visible-close] .icon-close {
  display: none;
}
.book-share-action {
  display: block;
  margin: 10px 16px 16px;
  width: calc(100% - 32px);
  min-height: 44px;
}
.detail-share-action {
  margin: 12px 0 20px;
  min-height: 44px;
}

/* Deep Blue: strong identity, restrained controls, shared geometry. */
:root {
  --brand-blue: #294c9d;
  --blue: #294c9d;
  --green: #294c9d;
  --paper: #ffffff;
  --pale: #eaf1ff;
  --line: #d8e1ef;
}
:root body :is(h1, h2, h3, h4, h5, h6) {
  color: #294c9d !important;
}
:root
  body
  :is(button, a.button-link, a.primary, a.secondary, a.button):not(.book-open):not(.rating-star) {
  box-sizing: border-box;
  max-width: 100%;
  min-height: 44px !important;
  padding: 9px 13px !important;
  border-radius: 8px !important;
  line-height: 1.35 !important;
  font-size: 14px !important;
  white-space: normal;
  vertical-align: middle;
  margin: 4px !important;
}
:root body button:not(.book-open):not(.rating-star):not(:disabled),
:root body :is(a.button-link, a.primary, a.secondary, a.button) {
  background: #fff !important;
  color: #294c9d !important;
  border: 1px solid #7788a6 !important;
  box-shadow: none !important;
  opacity: 1 !important;
}
:root body button.primary:not(:disabled),
:root body button[type='submit']:not(.secondary):not(.quiet):not(:disabled),
:root body a.primary {
  background: #294c9d !important;
  color: #fff !important;
  border-color: #294c9d !important;
}
:root body button.quiet:not(:disabled),
:root body :is(a.quiet, .contact-support) {
  background: transparent !important;
  border-color: transparent !important;
  color: #294c9d !important;
}
:root body button:not(.book-open):not(.rating-star):not(:disabled):hover,
:root body :is(a.button-link, a.secondary, a.button):hover {
  background: #eaf1ff !important;
  color: #203f84 !important;
  border-color: #6d80a3 !important;
}
:root body button.primary:not(:disabled):hover,
:root body button[type='submit']:not(.secondary):not(.quiet):not(:disabled):hover,
:root body a.primary:hover {
  background: #203f84 !important;
  color: #fff !important;
}
/* The popup × is an icon, not a boxed button: keep it round, borderless and large. */
:root
  body
  dialog[data-visible-close]
  > .popup-close-bar
  > button.popup-close-button:not(:disabled) {
  border: 0 !important;
  border-radius: 50% !important;
  background: #fff !important;
  color: #33476a !important;
  font-size: 28px !important;
  font-weight: 400 !important;
  line-height: 1 !important;
  min-height: 44px !important;
  min-width: 44px !important;
  padding: 0 !important;
}
:root
  body
  dialog[data-visible-close]
  > .popup-close-bar
  > button.popup-close-button:not(:disabled):hover {
  background: #f0f0f0 !important;
  color: #172f55 !important;
}
:root body button.danger:not(:disabled),
:root body button.delete:not(:disabled) {
  background: #fff !important;
  border-color: #d4aab4 !important;
  color: #983149 !important;
}
/* Margins protect ungrouped controls; wrapping rows use an exact 8px gap. */
:is(
  .actions,
  .local-actions,
  .header-actions,
  .modal-foot,
  .loan-card-actions,
  .book-actions,
  .todo-actions,
  .friend-toolbar,
  .friend-actions,
  .author-card-actions,
  .my-events-actions,
  .book-options,
  .event-rsvp-editor,
  .view-toggle,
  .tabs,
  .location-tabs,
  .community-tabs,
  #library-view-tabs,
  [role='tablist']
) {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center;
}
:root
  body
  :is(
    .actions,
    .local-actions,
    .header-actions,
    .modal-foot,
    .loan-card-actions,
    .book-actions,
    .todo-actions,
    .friend-toolbar,
    .friend-actions,
    .author-card-actions,
    .my-events-actions,
    .book-options,
    .event-rsvp-editor,
    .view-toggle,
    .tabs,
    .location-tabs,
    .community-tabs,
    #library-view-tabs,
    [role='tablist']
  )
  > :is(button, a.button-link, a.primary, a.secondary, a.button):not(.book-open):not(.rating-star) {
  margin: 0 !important;
}
:root body :is(.tabs, .location-tabs, .community-tabs, #library-view-tabs, [role='tablist']) button,
:root body button[role='tab'] {
  background: #fff !important;
  color: #294c9d !important;
  border: 1px solid #7788a6 !important;
  outline: none;
  box-shadow: none !important;
}
:root
  body
  :is(
    button[role='tab'][aria-selected='true'],
    .tabs button.active,
    .community-tabs button[aria-current='true'],
    .location-tabs button[aria-selected='true'],
    .location-tabs button[aria-current='true']
  ),
:root #library-view-tabs button[aria-pressed='true'] {
  background: #eaf1ff !important;
  color: #294c9d !important;
  border: 1px solid #6d80a3 !important;
  box-shadow: inset 0 -3px 0 #294c9d !important;
  font-weight: 700 !important;
}
:root #library-view-tabs button[aria-pressed='false'] {
  background: #fff !important;
  color: #294c9d !important;
  border: 1px solid #7788a6 !important;
  box-shadow: none !important;
}
:root body .summary-drill {
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  color: #294c9d !important;
}
:root body :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid #294c9d !important;
  outline-offset: 3px;
}
.password-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.password-field > input {
  flex: 1;
  min-width: 0;
  width: 0;
  margin: 0 !important;
}
:root body .password-field > button.password-visibility {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  padding: 6px !important;
  margin: 0 !important;
}
.password-visibility svg {
  display: block;
  pointer-events: none;
}
.saved-password-field input {
  font-size: 14px;
  padding: 8px;
  min-height: 44px;
}
.location-group {
  --location-tint: var(--paper) !important;
  background-color: var(--paper) !important;
}
.location-group:nth-of-type(even) {
  --location-tint: #f2f4f7 !important;
  background-color: #f2f4f7 !important;
}
.copyright {
  flex-basis: 100%;
  font: 13px/1.6 system-ui;
  color: #33476a;
  margin: 16px 0 0;
}
:root body .nav-help {
  background: #fff !important;
  color: #294c9d !important;
  border: 1px solid #7788a6 !important;
}
.app-nav {
  gap: 8px;
}
.app-menus {
  gap: 8px;
}
@media (max-width: 600px) {
  :root
    body
    :is(
      .header-actions,
      .modal-foot,
      .friend-toolbar,
      .friend-actions,
      .author-card-actions,
      .my-events-actions,
      .local-actions,
      .book-actions,
      .loan-card-actions
    ) {
    max-width: 100%;
    row-gap: 8px !important;
    column-gap: 8px !important;
  }
  :root body :is(.header-actions, .modal-foot) > button {
    flex: 0 1 auto;
    min-width: 0;
  }
}
[hidden] {
  display: none !important;
}
/* Semantic actions outrank the neutral button baseline. */
:root body button.primary:not(.book-open):not(.rating-star):not(:disabled),
:root
  body
  button[type='submit']:not(.secondary):not(.quiet):not(.book-open):not(.rating-star):not(
    :disabled
  ) {
  background: #294c9d !important;
  color: white !important;
  border-color: #294c9d !important;
}
:root body button.quiet:not(.book-open):not(.rating-star):not(:disabled) {
  background: transparent !important;
  border-color: transparent !important;
  color: #294c9d !important;
}
:root body .community-hero {
  background: #eaf1ff;
  color: #172f55;
}
:root body .community-hero .eyebrow {
  color: #294c9d !important;
}

:root body button.danger:not(.book-open):not(.rating-star):not(:disabled),
:root body button.delete:not(.book-open):not(.rating-star):not(:disabled) {
  background: white !important;
  border-color: #d4aab4 !important;
  color: #983149 !important;
}

/* Low-vision and color-independent control states. */
:root body {
  font-size: 16px;
  line-height: 1.5;
}
:root body :is(input, select, textarea) {
  font-size: 16px;
  line-height: 1.5;
  border-color: #7788a6 !important;
}
:root
  body
  :is(button, a.button-link, a.primary, a.secondary, a.button):not(.book-open):not(.rating-star) {
  font-size: 16px !important;
}
:root
  body
  :is(
    button[role='tab'][aria-selected='true'],
    .tabs button.active,
    .community-tabs button[aria-current='true'],
    .location-tabs button[aria-selected='true'],
    .location-tabs button[aria-current='true']
  ):not(.rating-star)::before,
:root #library-view-tabs button[aria-pressed='true']::before {
  content: '✓';
  display: inline-block;
  margin-right: 6px;
  font-weight: 800;
}
@media (prefers-contrast: more) {
  :root body :is(button, a.button-link, input, select, textarea) {
    border-width: 2px !important;
    border-color: #294c9d !important;
  }
  :root body .muted {
    color: #172f55 !important;
  }
}
@media (forced-colors: active) {
  :root body :is(button, a.button-link, a.primary, a.secondary, a.button, input, select, textarea) {
    forced-color-adjust: auto;
    background: Canvas !important;
    color: CanvasText !important;
    border: 2px solid ButtonText !important;
    box-shadow: none !important;
  }
  :root body :is(button, a, input, select, textarea):focus-visible {
    outline: 3px solid Highlight !important;
  }
  :root #library-view-tabs button[aria-pressed='true'] {
    border: 3px solid Highlight !important;
  }
}

.book-finished-celebration {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
  overflow: hidden;
}
.book-finished-message {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 14px 20px;
  background: #fff;
  color: #294c9d;
  border: 2px solid #294c9d;
  border-radius: 12px;
  box-shadow: 0 5px 24px #172f5520;
  font: 600 16px/1.5 system-ui;
  text-align: center;
}
.book-confetti {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 9px;
  height: 12px;
  border-radius: 2px;
  animation: book-confetti-burst 1.3s cubic-bezier(0.15, 0.65, 0.3, 1) both;
}
@keyframes book-confetti-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  62% {
    transform: translate(calc(-50% + var(--burst-x)), calc(-50% + var(--burst-y))) scale(1)
      rotate(240deg);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--end-x)), calc(-50% + var(--end-y))) scale(0.8)
      rotate(430deg);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .book-confetti {
    display: none !important;
    animation: none !important;
  }
}

/* Keep hold actions beside their list count, with space to wrap on phones. */
.collection-title {
  flex-wrap: wrap;
  gap: 12px;
}
#format-counts {
  line-height: 1.7;
  white-space: normal;
}

/* Library footer stays readable instead of squeezing into one flex row. */
footer.library-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  padding: 28px 0;
  background: #fff;
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: normal;
}
footer.library-footer strong {
  font-size: 22px;
  color: #294c9d;
}
footer.library-footer p {
  margin: 4px 0;
}
footer.library-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-content: start;
}
footer.library-footer a {
  padding: 4px 0;
  text-underline-offset: 3px;
}
footer.library-footer .library-footer-company {
  grid-column: 1/-1;
  border-top: 1px solid #d7dfec;
  padding-top: 16px;
}
@media (max-width: 600px) {
  footer.library-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
}

.import-enrichment {
  background: white;
  border: 1px solid #7788a6;
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
}
.import-enrichment summary {
  cursor: pointer;
}
.import-enrichment summary h2 {
  display: inline;
  margin: 0;
}
.import-enrichment details[open] summary {
  margin-bottom: 12px;
}
.import-enrichment progress {
  width: 100%;
  height: 16px;
  accent-color: #294c9d;
  margin-bottom: 12px;
}

.top-library-authors {
  background: #fff;
  border: 1px solid #7788a6;
  border-radius: 12px;
  padding: 22px;
  margin: 20px 0;
}
.top-library-authors p {
  line-height: 1.6;
}
.top-library-authors ol {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding-left: 24px;
  margin-bottom: 0;
}
.top-library-authors li {
  padding-left: 2px;
}
.top-library-authors button {
  white-space: normal;
  text-align: left;
}
.top-library-authors h2 {
  font-size: 28px;
}

/* Welcome-email previews inline the retired pastel page wash. The shared page token wins, and the message card keeps an edge on white. */
body[style*='#edf2ff'] {
  background-color: var(--paper) !important;
}
body[style*='#edf2ff'] [style*='background:#edf2ff'] {
  background-color: var(--paper) !important;
}
body[style*='#edf2ff'] table[style*='background:#fff'] {
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px #172f5514;
}

/* Header: Menu (left of the logo) and Help without outlines or the shared 4px button margin, so the logo sets the bar height. Focus ring and hover background stay. */
:root body .app-nav button.app-menu-toggle:not(:disabled),
:root body .app-nav button.app-menu-toggle:not(:disabled):hover,
:root body .app-nav .nav-help {
  border-color: transparent !important;
}
:root body .app-nav button.app-menu-toggle:not(:disabled) {
  order: -1;
  margin: 0 0 0 -8px !important;
  padding: 2px 8px !important;
  line-height: 1 !important;
}
:root body #nav-phone-tools > button:not(:disabled),
:root body #nav-phone-tools > button:not(:disabled):hover {
  border-color: transparent !important;
  margin: 0 !important;
}

/* Book details on phones: the action row is a wrapping line of text links (Read again | Edit | Lend …), not stacked boxes. Taps stay at least 32px tall. */
@media (max-width: 750px) {
  :root body #detail .book-actions.book-actions {
    gap: 0 !important;
    row-gap: 2px !important;
    padding: 8px 0 !important;
    margin: 0 0 8px -11px !important;
    border-bottom: 0 !important;
    overflow: hidden;
  }
  :root body #detail .book-actions.book-actions > small {
    padding-left: 11px;
  }
  :root body #detail .book-actions.book-actions > :is(button, a):not(.book-open):not(.rating-star) {
    min-height: 32px !important;
    padding: 4px 10px !important;
    border: 0 !important;
    border-left: 1px solid #c5cde0 !important;
    margin: 0 0 0 -1px !important;
    border-radius: 0 !important;
    background: none !important;
    box-shadow: none !important;
    color: #294c9d !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
  } /* Each link's divider sits 1px left of it, so the divider at the start of a wrapped line is clipped. */
  :root body #detail .book-actions.book-actions > [data-book-action='delete'] {
    color: #983149 !important;
  }
}

/* Library page filters: collection title and sheet, status tiles, format chips. Selected states use a dark orange border (5:1 on white) on a warm tint, not a blue wash. */
:root body .collection-switch {
  margin: 8px 0 12px;
  scroll-margin-top: 90px;
}
:root body #collection-open {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 2px 4px !important;
  margin-left: -4px !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--ink, #172033) !important;
  font:
    30px/1.15 'Libre Caslon Display',
    Georgia,
    serif !important;
  text-align: left;
}
:root body #collection-count {
  display: block;
  color: #4b5563;
  font-size: 14px;
}
:root body #pending-count {
  display: inline-block;
  margin-top: 4px;
  color: #294c9d;
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
}
:root body #status-tiles.status-tiles {
  display: flex;
  gap: 10px;
  margin: 0 0 12px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
:root body #status-tiles.status-tiles[hidden] {
  display: none !important;
}
:root body #status-tiles.status-tiles > button {
  flex: 1 0 92px;
  min-height: 76px;
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  margin: 0 !important;
  padding: 10px 12px !important;
  background: #fff !important;
  color: var(--ink, #172033) !important;
  border: 1px solid #c5cde0 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  text-align: left;
}
:root body #status-tiles.status-tiles > button[hidden] {
  display: none !important;
}
:root body #status-tiles.status-tiles strong {
  font:
    30px/1.1 'Libre Caslon Display',
    Georgia,
    serif;
  margin: 0;
}
:root body #status-tiles.status-tiles span {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
:root body #status-tiles.status-tiles > button[aria-pressed='true'] {
  border: 2px solid #b8441f !important;
  padding: 9px 11px !important;
  background: #fff5f0 !important;
}
:root body #format-chips.format-chips {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
:root body #format-chips.format-chips button {
  flex: 0 0 auto;
  min-height: 44px;
  margin: 0 !important;
  padding: 0 16px !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: var(--ink, #172033) !important;
  border: 1px solid #7788a6 !important;
  box-shadow: none !important;
  font-weight: 600;
  white-space: nowrap;
}
:root body #format-chips.format-chips button span {
  font-weight: 400;
  margin-left: 4px;
}
:root body #format-chips.format-chips button[aria-pressed='true'] {
  background: #172033 !important;
  color: #fff !important;
  border-color: #172033 !important;
}
:root
  body
  :is(#status-tiles button, #format-chips button, #collection-open, .collection-row):focus-visible {
  outline: 3px solid #2949d5 !important;
  outline-offset: 2px;
}
.collection-sheet {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(360px, calc(100vw - 32px));
  max-height: 70vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid #c5cde0;
  border-radius: 12px;
  background: #fff;
  color: var(--ink, #172033);
  box-shadow: 0 12px 32px rgba(23, 32, 51, 0.18);
}
.collection-sheet::backdrop {
  background: rgba(23, 32, 51, 0.25);
}
.collection-sheet h2 {
  font-size: 16px;
  margin: 4px 8px 4px;
}
.collection-sheet h3 {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4b5563;
  margin: 14px 8px 4px;
}
:root body #collection-sheet .collection-row {
  display: grid !important;
  grid-template-columns: 1fr auto 20px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 0 !important;
  padding: 8px !important;
  background: #fff !important;
  color: var(--ink, #172033) !important;
  border: 0 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  text-align: left;
  font-weight: 500;
}
:root body #collection-sheet .collection-row[aria-current='true'] {
  background: #fff5f0 !important;
  font-weight: 700;
}
.collection-row small {
  color: #4b5563;
}
.collection-check {
  color: #b8441f;
  font-weight: 800;
}
:root body #collection-sheet .collection-new {
  display: flex !important;
  color: #294c9d !important;
  font-weight: 600;
}
.state-badge {
  background: #fff !important;
  border: 1px solid #7788a6;
  color: #172033 !important;
}
.loan-due {
  font-size: 14px;
  color: #374151;
  margin: 6px 0 0;
}
@media (max-width: 750px) {
  .collection-sheet {
    top: auto !important;
    left: 0 !important;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
  }
  :root body #status-tiles.status-tiles > button {
    flex: 0 0 92px;
  }
  :root body #collection-open {
    font-size: 26px !important;
  }
}
:root body #format-chips.format-chips button[aria-pressed='true']:is(:hover, :focus) {
  background: #172033 !important;
  color: #fff !important;
}
:root body #status-tiles.status-tiles > button[aria-pressed='true']:is(:hover, :focus) {
  background: #fff5f0 !important;
}
