/* Final mobile touch-target, card rhythm, and narrow-screen refinements. */
@media (max-width: 760px) {
  .library-heading h1 {
    max-width: 12ch !important;
  }

  .book-grid {
    align-items: stretch !important;
  }

  .book-card {
    height: 100%;
  }

  .book-meta {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
  }

  .book-actions {
    margin-top: auto !important;
    padding-top: .8rem;
  }

  .cover-button,
  .book-actions .button,
  .dialog-close,
  .font-controls button,
  .theme-label select,
  .epub-link,
  .reader-nav button,
  .toc-toggle {
    touch-action: manipulation;
  }

  .book-actions .button,
  .font-controls button,
  .theme-label select,
  .epub-link,
  .reader-nav button {
    min-height: 2.75rem !important;
  }

  .book-actions .button {
    padding-block: .62rem !important;
  }

  .toc-toggle {
    top: .55rem !important;
    left: calc(100% + .55rem) !important;
    width: 2.75rem !important;
    min-height: 2.75rem !important;
    border: 1px solid var(--rule) !important;
    border-radius: .75rem !important;
    background: color-mix(in srgb, var(--surface) 96%, transparent) !important;
    box-shadow: 0 .4rem 1.25rem rgba(15, 20, 18, .14) !important;
    backdrop-filter: blur(12px);
  }

  .toc-toggle span:last-child {
    display: none !important;
  }

  .toc-toggle::after {
    content: "☰";
    font-size: 1.05rem;
    line-height: 1;
  }

  .toc-panel.open .toc-toggle {
    top: .6rem !important;
    right: .6rem !important;
    left: auto !important;
    z-index: 3;
    background: var(--surface) !important;
    box-shadow: none !important;
  }

  .toc-panel.open .toc-toggle::after {
    content: "×";
    font-size: 1.65rem;
    font-weight: 400;
  }

  .toc-panel.open #toc {
    padding-top: 4rem !important;
  }
}

@media (max-width: 340px) {
  .library-heading h1 {
    max-width: none !important;
    font-size: 2.35rem !important;
  }
}
