@media (max-width: 980px) {
  .modal-search-panel,
  .batch-toolbar,
  .editor-layout,
  .detail-layout {
    grid-template-columns: 1fr;
  }

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

  .detail-cover,
  .preview-panel .detail-cover {
    max-width: 16rem;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .catalogue-page.catalogue-condensed .search-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 1.5rem, 100%);
    padding-top: 0.55rem;
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom, 0px));
  }

  .page > .card,
  .page > .hero,
  .page > .form-panel,
  .page > .empty-state {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .topbar,
  .topbar-actions,
  .topbar-nav,
  .topbar-utility,
  .toolbar,
  .result-actions,
  .form-actions,
  .hero-header,
  .hero-actions,
  .toolbar-end,
  .section-heading,
  .integration-summary,
  .detail-actions,
  .detail-header {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    padding: 0.1rem 0 0.55rem;
  }

  .brand-block {
    min-width: 0;
    padding-left: 1rem;
    flex: 1 1 auto;
  }

  .catalogue-controls {
    top: calc(var(--catalogue-topbar-height) - 1px);
    gap: 0.6rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    padding-top: 0;
    padding-bottom: 0.65rem;
  }

  .page-title {
    font-size: clamp(2rem, 10vw, 2.8rem);
  }

  .stats,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .cover-grid,
  .shelf-grid {
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  }

  .brand-kicker,
  .tagline,
  .section-subtitle {
    display: none;
  }

  .topbar-library-size {
    font-size: 0.74rem;
    padding: 0.3rem 0.58rem;
  }

  .brand {
    font-size: 1.1rem;
    letter-spacing: 0.06em;
  }

  .topbar-actions {
    display: none;
  }

  .mobile-topbar-menu {
    position: relative;
    display: block;
    width: auto;
    margin-left: auto;
    flex: 0 0 auto;
  }

  body.selection-mode-active .mobile-topbar-menu {
    display: none;
  }

  .mobile-menu-trigger {
    width: auto;
    min-height: 2.75rem;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border);
    background: rgba(255, 253, 249, 0.78);
    justify-content: center;
    gap: 0.45rem;
    list-style: none;
    cursor: pointer;
  }

  .mobile-topbar-menu > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-menu-sheet {
    position: absolute;
    right: 0;
    min-width: 13rem;
    margin-top: 0.45rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    background: rgba(251, 248, 242, 0.98);
  }

  .hero-header {
    gap: 0.5rem;
  }

  .section-heading {
    display: flex;
    flex-direction: row;
    align-items: end;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.6rem;
  }

  .section-heading > :first-child {
    flex: 1 1 auto;
    min-width: 0;
  }

  .section-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .search-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
    align-items: stretch;
  }

  .search-field {
    grid-column: auto;
  }

  .search-panel .field label,
  .catalogue-view-switch .field label {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
  }

  .search-panel .field input,
  .search-panel .field select,
  .search-panel .button,
  .catalogue-view-switch .field select,
  .filter-chip {
    min-height: 2.75rem;
    padding: 0.68rem 0.8rem;
  }

  .search-bar-shell {
    min-height: 3.1rem;
    padding-left: 0.5rem;
    padding-right: 0.32rem;
    background: rgba(255, 253, 249, 0.92);
  }

  .search-bar-action {
    width: 2.35rem;
    min-width: 2.35rem;
    height: 2.35rem;
  }

  .catalogue-view-switch {
    display: grid;
    grid-template-columns: minmax(6.8rem, 8.2rem) auto;
    align-items: end;
    gap: 0.65rem;
    width: auto;
    margin-left: auto;
    flex: 0 0 auto;
    flex-direction: row;
  }

  .catalogue-heading-action {
    align-self: end;
  }

  .catalogue-view-switch {
    border-left: 0;
    padding-left: 0;
  }

  .catalogue-mobile-hide {
    display: none !important;
  }

  .catalogue-filters-toggle {
    display: inline-flex;
  }

  .catalogue-filters-toggle .section-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
  }

  .catalogue-heading-title-desktop {
    display: none;
  }

  .catalogue-mobile-shelf-filter {
    min-width: 0;
    width: auto;
  }

  .catalogue-mobile-shelf-filter label {
    display: none;
  }

  .catalogue-mobile-shelf-filter select {
    width: 100%;
  }

  .catalogue-layout-switch {
    display: flex;
    flex-direction: row;
    align-items: end;
    gap: 0.45rem;
    min-width: auto;
    justify-self: end;
  }

  .catalogue-layout-switch .meta-label {
    display: none;
  }

  .catalogue-layout-switch .result-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
  }

  .catalogue-layout-button {
    flex: 0 0 2.6rem;
    width: 2.6rem;
    min-width: 2.6rem;
    min-height: 2.75rem;
    padding: 0.45rem;
  }

  .catalogue-view-form,
  .catalogue-view-switch .field,
  .inline-filter-group {
    flex: 0 0 auto;
    min-width: 8.5rem;
  }

  .search-sort-field {
    display: none;
  }

  .mobile-status-filter {
    display: grid;
  }

  .filter-strip {
    display: none;
  }

  .settings-tabs {
    display: flex;
    margin-left: 0.4rem;
    margin-right: 0.4rem;
    padding-bottom: 0.1rem;
  }

  .settings-tab {
    width: auto;
    min-width: max-content;
    padding-left: 0.95rem;
    padding-right: 0.95rem;
  }

  .mobile-catalogue-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .mobile-catalogue-tab-form .filter-chip {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .mobile-advanced-filters {
    display: block;
    border-top: 1px solid var(--border);
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    padding-top: 0.2rem;
  }

  .mobile-advanced-filters > summary {
    display: none;
  }

  .mobile-advanced-filters > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-advanced-filters-body {
    display: grid;
    gap: 0.75rem;
    padding-top: 0.7rem;
  }

  .mobile-advanced-actions {
    justify-content: stretch;
  }

  .mobile-advanced-actions .button {
    width: 100%;
  }

  .mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 0.75rem 0.85rem calc(0.8rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(30, 35, 41, 0.07);
    background:
      linear-gradient(180deg, rgba(255, 252, 246, 0.88), rgba(247, 242, 233, 0.96));
    backdrop-filter: blur(20px);
    box-shadow: 0 -12px 34px rgba(30, 35, 41, 0.1);
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .mobile-bottom-bar.mobile-bottom-bar-hidden {
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
    opacity: 0.92;
  }

  .mobile-bottom-link {
    cursor: pointer;
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.3rem;
    min-height: 4.15rem;
    padding: 0.55rem 0.4rem 0.48rem;
    border: 1px solid rgba(91, 94, 96, 0.16);
    background: linear-gradient(180deg, rgba(255, 254, 251, 0.9), rgba(244, 239, 231, 0.88));
    color: rgba(30, 35, 41, 0.8);
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 1rem;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.75),
      0 6px 18px rgba(73, 62, 43, 0.08);
    transition:
      border-color 160ms ease,
      background-color 160ms ease,
      box-shadow 160ms ease,
      color 160ms ease,
      transform 160ms ease;
  }

  .mobile-bottom-link.active,
  .mobile-bottom-link-primary {
    color: var(--accent);
    border-color: rgba(29, 77, 69, 0.24);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.75),
      0 10px 24px rgba(29, 77, 69, 0.14);
  }

  .mobile-bottom-link:focus-visible {
    outline: 2px solid rgba(29, 77, 69, 0.22);
    outline-offset: 2px;
  }

  .mobile-bottom-link::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(29, 77, 69, 0), rgba(29, 77, 69, 0));
    transform: scale(0.9);
    opacity: 0;
    transition:
      opacity 180ms ease,
      transform 180ms ease,
      background-color 180ms ease;
  }

  .mobile-bottom-link.active::before,
  .mobile-bottom-link-primary::before {
    background: linear-gradient(180deg, rgba(29, 77, 69, 0.08), rgba(29, 77, 69, 0.14));
    transform: scale(1);
    opacity: 1;
  }

  .mobile-bottom-link .mobile-nav-icon-wrap,
  .mobile-bottom-link .mobile-bottom-label {
    position: relative;
    z-index: 1;
  }

  .mobile-bottom-link .mobile-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.56);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
    transform: translateY(0);
    transition:
      background-color 180ms ease,
      box-shadow 180ms ease,
      transform 180ms ease,
      color 180ms ease;
  }

  .mobile-bottom-link.active .mobile-nav-icon,
  .mobile-bottom-link-primary .mobile-nav-icon {
    transform: translateY(-0.08rem) scale(1.04);
    background: rgba(255, 252, 247, 0.9);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.82),
      0 4px 14px rgba(29, 77, 69, 0.12);
  }

  .mobile-bottom-label {
    display: block;
    white-space: normal;
    line-height: 1.12;
    max-width: 6.5rem;
    transition:
      color 180ms ease,
      transform 180ms ease,
      opacity 180ms ease;
  }

  .mobile-bottom-link.active .mobile-bottom-label,
  .mobile-bottom-link-primary .mobile-bottom-label {
    transform: translateY(-0.04rem);
  }

  .barcode-scanner-modal {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    border: 0;
    background: rgba(11, 16, 18, 0.98);
    color: #f5f5f3;
    overflow-x: hidden;
  }

  .barcode-scanner-sheet {
    min-height: 100vh;
    padding: calc(0.8rem + env(safe-area-inset-top, 0px)) 0.9rem calc(1rem + env(safe-area-inset-bottom, 0px));
    grid-template-rows: auto 1fr;
    width: 100%;
    min-width: 0;
  }

  .barcode-scanner-topbar {
    align-items: start;
    flex-wrap: wrap;
  }

  .barcode-scanner-topbar .section-title,
  .barcode-scanner-topbar .eyebrow {
    color: #f5f5f3;
  }

  .barcode-scanner-close,
  .barcode-scanner-rescan.button.ghost {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.1);
    color: #f5f5f3;
  }

  .barcode-scanner-stage {
    align-content: space-between;
  }

  .barcode-scanner-frame {
    min-height: min(58vh, 30rem);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .barcode-scanner-status-card {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(16, 24, 27, 0.92);
  }

  .barcode-scanner-status-card .meta-line,
  .barcode-scanner-hint {
    color: rgba(245, 245, 243, 0.82);
  }

  .barcode-scanner-debug {
    color: rgba(245, 245, 243, 0.72);
  }

  .barcode-scanner-actions {
    flex-wrap: wrap;
  }

  .barcode-upload-trigger,
  .barcode-scanner-actions .button {
    width: 100%;
  }

  .camera-modal-actions {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .barcode-action-card {
    min-height: 4.15rem;
    padding: 0.55rem 0.4rem 0.48rem;
  }

  .batch-toolbar {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    transform: translateY(calc(100% + 1rem + env(safe-area-inset-bottom, 0px)));
    grid-template-columns: 1fr;
    gap: 0.85rem;
    z-index: 61;
    padding: 0.8rem 0.8rem 0.9rem;
    max-height: min(68vh, 34rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .batch-toolbar.selection-active,
  .batch-toolbar[data-selection-visible="true"] {
    transform: translateY(0);
    max-height: min(68vh, 34rem);
  }

  .batch-toolbar.batch-toolbar-with-bottom-nav {
    bottom: calc(var(--mobile-bottom-bar-height) + 1rem + env(safe-area-inset-bottom, 0px));
  }

  .batch-action-group,
  .batch-target-slot {
    min-width: 0;
  }

  .batch-target-slot .batch-field-group {
    min-width: 0;
  }

  .online-results-toolbar.online-results-toolbar-with-bottom-nav {
    bottom: calc(var(--mobile-bottom-bar-height) + 1rem + env(safe-area-inset-bottom, 0px));
  }

  .batch-selection-meta .result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
  }

  .batch-selection-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.75rem;
    align-items: center;
  }

  .batch-selection-meta > .eyebrow {
    margin: 0;
  }

  .selection-clear-icon {
    width: 2.2rem;
    min-width: 2.2rem;
    min-height: 2.2rem;
    padding: 0;
    border-radius: 0.7rem;
    font-size: 0.95rem;
  }

  .bulk-select-toggle {
    justify-self: end;
    align-self: start;
    min-height: auto;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .batch-field-group {
    gap: 0.4rem;
  }

  .batch-toolbar .batch-selector-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
    grid-column: 1 / -1;
  }

  .batch-toolbar .field.batch-action-group,
  .batch-toolbar .batch-target-slot,
  .batch-toolbar .batch-target-slot .batch-field-group {
    min-width: 0;
  }

  .batch-toolbar .field.batch-action-group,
  .batch-toolbar .batch-target-slot .batch-field-group {
    display: grid;
    gap: 0.4rem;
  }

  .batch-toolbar .batch-apply-wrap {
    grid-column: 3;
    align-self: end;
  }

  .batch-toolbar .field.batch-action-group > select,
  .batch-toolbar .batch-target-slot .batch-field-group > select {
    width: 100%;
    min-width: 0;
  }

  .batch-field-group-hidden {
    display: none;
  }

  .batch-field-group > label,
  .batch-field-group > .eyebrow {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
  }

  .batch-toolbar .field select,
  .batch-toolbar .button {
    min-height: 2.65rem;
  }

  .batch-toolbar .toolbar-end.batch-apply-wrap {
    width: auto;
    justify-content: flex-end;
    padding-top: 0;
    padding-bottom: 0.45rem;
    background: none;
    position: static;
    z-index: auto;
  }

  .batch-toolbar .toolbar-end.batch-apply-wrap .button {
    width: auto;
    min-width: 5.5rem;
    flex: 0 0 auto;
  }

  .batch-delete-confirm-modal {
    width: calc(100vw - 1rem);
    max-width: calc(100vw - 1rem);
  }

  .batch-undo-toast {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: calc(var(--mobile-bottom-bar-height) + 1rem + env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  .profile-password-modal {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    border: 0;
    background: rgba(11, 16, 18, 0.98);
    color: #f5f5f3;
  }

  .profile-password-sheet {
    min-height: 100vh;
    padding: calc(0.8rem + env(safe-area-inset-top, 0px)) 0.9rem calc(1rem + env(safe-area-inset-bottom, 0px));
    width: 100%;
  }

  .profile-password-topbar {
    align-items: flex-start;
    gap: 0.9rem;
  }

  .profile-password-topbar .section-title,
  .profile-password-topbar .eyebrow,
  .profile-password-topbar .section-subtitle {
    color: #f5f5f3;
  }

  .profile-password-close {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.1);
    color: #f5f5f3;
  }

  .quick-batch-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 0.65rem;
    align-items: end;
  }

  .quick-batch-actions .button {
    width: 100%;
    min-width: 0;
  }

  .quick-batch-actions .selection-clear-icon {
    align-self: center;
    justify-self: end;
    margin-bottom: 0.05rem;
  }
}

@media (max-width: 1120px) {
  .cover-grid:not(.cover-grid-row) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .cover-grid:not(.cover-grid-row) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.cover-grid.cover-grid-online:not(.online-series-grid):has([data-deferred-cover-root]) {
  grid-template-columns: auto;
}

@media (prefers-reduced-motion: reduce) {
  .batch-toolbar {
    transition: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 1.25rem, 100%);
  }

  .page > .card,
  .page > .hero,
  .page > .form-panel,
  .page > .empty-state {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  .catalogue-controls,
  .mobile-catalogue-tabs,
  .mobile-advanced-filters,
  .catalog-pages,
  .lookup-results,
  .detail-layout,
  .editor-layout,
  .shelf-grid,
  .cover-grid {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .cover-grid,
  .shelf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .cover-card-row {
    grid-column: 1 / -1;
  }

  .button,
  .nav-link,
  .nav-button,
  .filter-chip {
    width: 100%;
  }

  .filter-chip {
    padding-left: 0;
    padding-right: 0;
  }

  .search-primary-actions,
  .search-secondary-actions,
  .catalogue-view-switch {
    width: 100%;
  }

  .catalogue-view-switch {
    width: auto;
    flex: 0 0 auto;
  }

  .search-primary-actions .button,
  .search-secondary-actions .button,
  .catalogue-view-switch .filter-chip {
    width: auto;
  }

  .search-bar-shell {
    min-height: 3.1rem;
  }

  /* Stack the batch toolbar row controls vertically so each dropdown gets
     full width. The ≤760px breakpoint puts them in a 3-column row that
     leaves ~140px per dropdown on a 390px phone — too narrow to read shelf
     names. Stacking also makes the Apply button a clear, full-width tap
     target at the bottom of the sheet. */
  .batch-toolbar .batch-selector-row {
    grid-template-columns: 1fr;
  }

  .batch-toolbar .batch-apply-wrap {
    grid-column: 1;
    align-self: stretch;
  }

  .batch-toolbar .toolbar-end.batch-apply-wrap {
    justify-content: stretch;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  }

  .batch-toolbar .toolbar-end.batch-apply-wrap .button {
    width: 100%;
    min-width: unset;
  }

  .batch-toolbar .field.batch-action-group > select,
  .batch-toolbar .batch-target-slot .batch-field-group > select {
    font-size: 1rem; /* prevents iOS auto-zoom on focus */
  }
}

@media (max-width: 420px) {
  .cover-grid:not(.cover-grid-row),
  .shelf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

/* Mobile M3-style scan FAB. Replaces the old mobile bottom bar. */
.mobile-scan-fab {
  display: none;
}

@media (max-width: 760px) {
  .mobile-bottom-bar {
    display: none !important;
  }

  .mobile-scan-fab {
    appearance: none;
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(1.3rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 70;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 5.5rem;
    height: 5.5rem;
    min-width: 4rem;
    min-height: 4rem;
    padding: 0;

    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: #f8fbf9;
    cursor: pointer;

    box-shadow:
      0 6px 16px rgba(30, 35, 41, 0.18),
      0 10px 28px rgba(29, 77, 69, 0.22);

    -webkit-tap-highlight-color: transparent;

    transition:
      transform 180ms ease,
      opacity 180ms ease,
      box-shadow 180ms ease,
      background-color 180ms ease;
  }

  .mobile-scan-fab:hover,
  .mobile-scan-fab:focus-visible {
    background: color-mix(in srgb, var(--accent) 88%, white 12%);
    box-shadow:
      0 8px 18px rgba(30, 35, 41, 0.2),
      0 14px 34px rgba(29, 77, 69, 0.26);
  }

  .mobile-scan-fab:focus-visible {
    outline: 3px solid rgba(29, 77, 69, 0.24);
    outline-offset: 3px;
  }

  .mobile-scan-fab:active {
    transform: translateX(-50%) scale(0.96);
  }

  .mobile-scan-fab svg {
    width: 2rem;
    height: 2rem;
    min-width: 1.65rem;
    min-height: 1.65rem;
    fill: currentColor;
  }

  .mobile-scan-fab-hidden {
    transform: translateX(-50%) translateY(calc(100% + 1.5rem + env(safe-area-inset-bottom, 0px)));
    opacity: 0;
    pointer-events: none;
  }

  body.selection-mode-active .mobile-scan-fab,
  body:has(.online-results-toolbar.selection-active) .mobile-scan-fab,
  body:has(.online-results-toolbar[data-selection-visible="true"]) .mobile-scan-fab {
    transform: translateX(-50%) translateY(calc(100% + 1.5rem + env(safe-area-inset-bottom, 0px)));
    opacity: 0;
    pointer-events: none;
  }

  /* Online-results toolbar: stack columns vertically on mobile, matching the
     batch-toolbar treatment. Desktop uses a 5-column grid that is far too
     wide for phone viewports. */
  .online-results-toolbar {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    transform: translateX(0) translateY(calc(100% + 1rem + env(safe-area-inset-bottom, 0px)));
    grid-template-columns: 1fr;
    gap: 0.85rem;
    z-index: 61;
    padding: 0.8rem 0.8rem 0.9rem;
    max-height: min(68vh, 34rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .online-results-toolbar.selection-active,
  .online-results-toolbar[data-selection-visible="true"] {
    transform: translateX(0) translateY(0);
  }

  .online-results-toolbar .batch-selection-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.35rem 0.75rem;
    align-items: center;
  }

  .online-results-toolbar .batch-field-group {
    gap: 0.4rem;
  }

  .online-results-toolbar .batch-field-group select {
    width: 100%;
    min-height: 2.65rem;
    font-size: 1rem; /* prevent iOS auto-zoom */
  }

  /* Show Clear + Add Selected side by side as a full-width pair. */
  .online-results-button-row {
    display: flex;
    gap: 0.6rem;
  }

  .online-results-button-row .quick-batch-actions {
    flex: 1 1 0;
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .online-results-button-row .button {
    width: 100%;
    min-height: 2.65rem;
  }

  /* The save-mode note adds no interactivity — hide it on mobile to keep
     the sheet compact. */
  .online-results-save-mode-note {
    display: none;
  }

  .barcode-scanner-modal[data-isbn-scanner-modal] {
    width: min(34rem, calc(100vw));
    max-width: calc(100vw);
    margin: 0px auto;
    padding-top: 5vh;
  }

  .barcode-scanner-modal[data-isbn-scanner-modal] .barcode-scanner-frame {
    min-height: min(76vh, 760px);
    height: min(76vh, 760px);
    max-height: 82vh;
  }

  .barcode-scanner-modal[data-isbn-scanner-modal] .barcode-scanner-frame video {
    min-height: 100%;
  }
}

@media (min-width: 761px) {
  .mobile-scan-fab {
    display: none !important;
  }
}

@media (max-width: 760px) {
  .barcode-scanner-modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0b1012;
    overflow: hidden;
  }

  .barcode-scanner-modal::backdrop {
    background: #0b1012;
  }

  .barcode-scanner-sheet {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
    display: block;
    overflow: hidden;
    position: relative;
  }

  .barcode-scanner-stage {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: block;
    position: relative;
    overflow: hidden;
  }

  .barcode-scanner-frame {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: #0f1418;
    position: relative;
  }

  .barcode-scanner-frame video,
  .barcode-scanner-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .barcode-scanner-status-card {
    display: none !important;
  }

  .barcode-scanner-topbar {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
  }

  .barcode-scanner-topbar > *:not([data-close-isbn-scanner]) {
    display: none !important;
  }

  [data-close-isbn-scanner] {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 30;

    width: 4rem;
    height: 4rem;
    min-width: 4rem;
    min-height: 4rem;
    padding: 0;
    margin: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 999px;
    background: #d32f2f;
    color: transparent;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;

    box-shadow:
      0 6px 16px rgba(0, 0, 0, 0.28),
      0 12px 28px rgba(211, 47, 47, 0.25);

    transition:
      transform 180ms ease,
      box-shadow 180ms ease,
      background-color 180ms ease;
  }

  [data-close-isbn-scanner]::before {
    content: "✕";
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 700;
  }

  [data-close-isbn-scanner]:active {
    transform: translateX(-50%) scale(0.96);
  }

  [data-close-isbn-scanner]:focus-visible {
    outline: 3px solid rgba(211, 47, 47, 0.28);
    outline-offset: 3px;
  }

  .barcode-scanner-frame::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(6.25rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 12;

    width: 0.9rem;
    height: 0.9rem;
    border-radius: 999px;
    background: #42d392;
    box-shadow: 0 0 0 0 rgba(66, 211, 146, 0.65);
    animation: isbn-scan-pulse 1.6s infinite ease-out;
    pointer-events: none;
  }

  .barcode-scanner-frame::before {
    content: "Scanning...";
    position: absolute;
    left: 50%;
    bottom: calc(4.85rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 12;

    color: rgba(255, 255, 255, 0.92);
    font-size: 0.8rem;
    line-height: 1;
    letter-spacing: 0.02em;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  }

  @keyframes isbn-scan-pulse {
    0% {
      transform: translateX(-50%) scale(1);
      box-shadow: 0 0 0 0 rgba(66, 211, 146, 0.65);
      opacity: 1;
    }

    70% {
      transform: translateX(-50%) scale(1.15);
      box-shadow: 0 0 0 16px rgba(66, 211, 146, 0);
      opacity: 0.95;
    }

    100% {
      transform: translateX(-50%) scale(1);
      box-shadow: 0 0 0 0 rgba(66, 211, 146, 0);
      opacity: 1;
    }
  }
}

@media (max-width: 760px) {
  dialog[data-cover-identify-modal][open] {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    min-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0b1012;
    overflow: hidden;
  }

  dialog[data-cover-identify-modal][open]::backdrop {
    background: #0b1012;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-sheet,
  dialog[data-cover-identify-modal][open] .cover-camera-stage,
  dialog[data-cover-identify-modal][open] .cover-camera-frame {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-width: 100vw;
    min-height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0b1012;
    overflow: hidden;
  }

  dialog[data-cover-identify-modal][open] [data-cover-camera-video],
  dialog[data-cover-identify-modal][open] [data-cover-camera-preview] {
    position: absolute;
    inset: 0;
    display: block;
    width: 100vw;
    height: 100dvh;
    object-fit: cover;
    background: #0b1012;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-topbar,
  dialog[data-cover-identify-modal][open] .cover-camera-status-card {
    display: none !important;
  }

  dialog[data-cover-identify-modal][open] .barcode-scan-reticle-cover {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-book-frame,
  dialog[data-cover-identify-modal][open] [data-cover-camera-crop-guide] {
    position: absolute;
    left: 50%;
    top: 44%;

    width: 20rem;
    max-width: calc(100vw - 3rem);
    aspect-ratio: 2 / 3;
    height: auto;

    transform: translate(-50%, -50%);
    border: 3px solid rgba(255, 255, 255, 0.96);
    border-radius: 1rem;
    box-sizing: border-box;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    background: transparent;
    pointer-events: none;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-bar {
    position: fixed;
    left: 50%;
    bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: auto;
    padding: 0;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    min-width: 4rem;
    min-height: 4rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab:active {
    transform: scale(0.96);
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: currentColor;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-cancel,
  dialog[data-cover-identify-modal][open] .cover-camera-fab-retake {
    background: rgba(18, 24, 28, 0.88);
    backdrop-filter: blur(10px);
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-capture {
    background: #ffffff;
    color: #111;
    width: 4.5rem;
    height: 4.5rem;
    min-width: 4.5rem;
    min-height: 4.5rem;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-retake.hidden {
    display: none !important;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-icon-confirm {
    display: none;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-capture[data-cover-capture-mode="confirm"] {
    background: #1f9d55;
    color: #fff;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-capture[data-cover-capture-mode="confirm"] .cover-camera-fab-icon-camera {
    display: none;
  }

  dialog[data-cover-identify-modal][open] .cover-camera-fab-capture[data-cover-capture-mode="confirm"] .cover-camera-fab-icon-confirm {
    display: inline-flex;
  }
}
